mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2026-01-01 22:29:15 +03:00
Better submission error message
This commit is contained in:
@@ -20,7 +20,7 @@ import { parseUserAgent } from "../utils/userAgent";
|
||||
import { getService } from "../utils/getService";
|
||||
import axios from "axios";
|
||||
import { vote } from "./voteOnSponsorTime";
|
||||
import { canSubmit } from "../utils/permissions";
|
||||
import { canSubmit, canSubmitGlobal } from "../utils/permissions";
|
||||
import { getVideoDetails, videoDetails } from "../utils/getVideoDetails";
|
||||
import * as youtubeID from "../utils/youtubeID";
|
||||
import { acquireLock } from "../utils/redisLock";
|
||||
@@ -509,6 +509,11 @@ export async function postSkipSegments(req: Request, res: Response): Promise<Res
|
||||
}
|
||||
const userID: HashedUserID = await getHashCache(paramUserID);
|
||||
|
||||
const permission = await canSubmitGlobal(userID);
|
||||
if (!permission.canSubmit) {
|
||||
return res.status(403).send(permission.reason);
|
||||
}
|
||||
|
||||
const invalidCheckResult = await checkInvalidFields(videoID, paramUserID, userID, segments, videoDurationParam, userAgent, service);
|
||||
if (!invalidCheckResult.pass) {
|
||||
return res.status(invalidCheckResult.errorCode).send(invalidCheckResult.errorMessage);
|
||||
|
||||
@@ -23,14 +23,14 @@ async function oldSubmitter(userID: HashedUserID): Promise<boolean> {
|
||||
const result = await db.prepare("get", `SELECT count(*) as "submissionCount" FROM "sponsorTimes" WHERE "userID" = ? AND "timeSubmitted" < 1743827196000`
|
||||
, [userID], { useReplica: true });
|
||||
|
||||
return result.submissionCount > 1;
|
||||
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;
|
||||
return result.submissionCount >= 1;
|
||||
}
|
||||
|
||||
export async function canSubmit(userID: HashedUserID, category: Category): Promise<CanSubmitResult> {
|
||||
@@ -45,13 +45,20 @@ export async function canSubmit(userID: HashedUserID, category: Category): Promi
|
||||
reason: "Submitting chapters requires a minimum reputation. You can ask on Discord/Matrix to get permission with less reputation."
|
||||
};
|
||||
default:
|
||||
return {
|
||||
canSubmit: true,
|
||||
reason: ""
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function canSubmitGlobal(userID: HashedUserID): Promise<CanSubmitResult> {
|
||||
return {
|
||||
canSubmit: await oneOf([isUserVIP(userID),
|
||||
oldSubmitter(userID)
|
||||
]),
|
||||
reason: "We are currently experiencing a mass spam attack, we are restricting submissions for now"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function canVote(userID: HashedUserID): Promise<CanSubmitResult> {
|
||||
|
||||
Reference in New Issue
Block a user