mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 03:26:59 +03:00
Change dearrow permission requirements
This commit is contained in:
@@ -18,7 +18,7 @@ import { checkBanStatus } from "../utils/checkBan";
|
||||
import axios from "axios";
|
||||
import { getMaxResThumbnail } from "../utils/youtubeApi";
|
||||
import { getVideoDetails } from "../utils/getVideoDetails";
|
||||
import { canSubmitGlobal } from "../utils/permissions";
|
||||
import { canSubmitDeArrow } from "../utils/permissions";
|
||||
|
||||
enum BrandingType {
|
||||
Title,
|
||||
@@ -56,7 +56,7 @@ export async function postBranding(req: Request, res: Response) {
|
||||
const hashedIP = await getHashCache(getIP(req) + config.globalSalt as IPAddress);
|
||||
const isBanned = await checkBanStatus(hashedUserID, hashedIP);
|
||||
|
||||
const permission = await canSubmitGlobal(hashedUserID);
|
||||
const permission = await canSubmitDeArrow(hashedUserID);
|
||||
if (!permission.canSubmit) {
|
||||
res.status(403).send(permission.reason);
|
||||
return;
|
||||
|
||||
@@ -13,7 +13,7 @@ import crypto from "crypto";
|
||||
import { QueryCacher } from "../utils/queryCacher";
|
||||
import { acquireLock } from "../utils/redisLock";
|
||||
import { checkBanStatus } from "../utils/checkBan";
|
||||
import { canSubmitGlobal } from "../utils/permissions";
|
||||
import { canSubmitDeArrow } from "../utils/permissions";
|
||||
|
||||
interface ExistingVote {
|
||||
UUID: BrandingUUID;
|
||||
@@ -42,7 +42,7 @@ export async function postCasual(req: Request, res: Response) {
|
||||
const hashedIP = await getHashCache(getIP(req) + config.globalSalt as IPAddress);
|
||||
const isBanned = await checkBanStatus(hashedUserID, hashedIP);
|
||||
|
||||
const permission = await canSubmitGlobal(hashedUserID);
|
||||
const permission = await canSubmitDeArrow(hashedUserID);
|
||||
if (!permission.canSubmit) {
|
||||
res.status(403).send(permission.reason);
|
||||
return;
|
||||
|
||||
@@ -17,7 +17,7 @@ import { getVideoDetails, videoDetails } from "../utils/getVideoDetails";
|
||||
import { deleteLockCategories } from "./deleteLockCategories";
|
||||
import { acquireLock } from "../utils/redisLock";
|
||||
import { checkBanStatus } from "../utils/checkBan";
|
||||
import { canSubmitGlobal } from "../utils/permissions";
|
||||
import { canVote } from "../utils/permissions";
|
||||
|
||||
const voteTypes = {
|
||||
normal: 0,
|
||||
@@ -343,7 +343,7 @@ export async function vote(ip: IPAddress, UUID: SegmentUUID, paramUserID: UserID
|
||||
const nonAnonUserID = await getHashCache(paramUserID);
|
||||
const userID = await getHashCache(paramUserID + UUID);
|
||||
|
||||
const permission = await canSubmitGlobal(nonAnonUserID);
|
||||
const permission = await canVote(nonAnonUserID);
|
||||
if (!permission.canSubmit) {
|
||||
return {
|
||||
status: 403,
|
||||
|
||||
@@ -26,6 +26,13 @@ async function oldSubmitter(userID: HashedUserID): Promise<boolean> {
|
||||
return result.submissionCount > 1;
|
||||
}
|
||||
|
||||
async function oldDeArrowSubmitter(userID: HashedUserID): Promise<boolean> {
|
||||
const result = await db.prepare("get", `SELECT count(*) as "submissionCount" FROM "titles" WHERE "userID" = ? AND "timeSubmitted" < 1743827196000`
|
||||
, [userID], { useReplica: true });
|
||||
|
||||
return result.submissionCount > 1;
|
||||
}
|
||||
|
||||
export async function canSubmit(userID: HashedUserID, category: Category): Promise<CanSubmitResult> {
|
||||
switch (category) {
|
||||
case "chapter":
|
||||
@@ -42,16 +49,25 @@ export async function canSubmit(userID: HashedUserID, category: Category): Promi
|
||||
canSubmit: await oneOf([isUserVIP(userID),
|
||||
oldSubmitter(userID)
|
||||
]),
|
||||
reason: "We are currently experiencing a mass spam attack"
|
||||
reason: "We are currently experiencing a mass spam attack, we are restricting submissions for now"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function canSubmitGlobal(userID: HashedUserID): Promise<CanSubmitResult> {
|
||||
export async function canVote(userID: HashedUserID): Promise<CanSubmitResult> {
|
||||
return {
|
||||
canSubmit: await oneOf([isUserVIP(userID),
|
||||
oldSubmitter(userID)
|
||||
]),
|
||||
reason: "We are currently experiencing a mass spam attack"
|
||||
reason: "We are currently experiencing a mass spam attack, we are restricting submissions for now"
|
||||
};
|
||||
}
|
||||
|
||||
export async function canSubmitDeArrow(userID: HashedUserID): Promise<CanSubmitResult> {
|
||||
return {
|
||||
canSubmit: await oneOf([isUserVIP(userID),
|
||||
oldDeArrowSubmitter(userID)
|
||||
]),
|
||||
reason: "We are currently experiencing a mass spam attack, we are restricting submissions for now"
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user