mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-13 06:57:05 +03:00
Add another option to get chapters submitting permission
This commit is contained in:
@@ -12,11 +12,19 @@ interface CanSubmitResult {
|
|||||||
reason?: string;
|
reason?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function lowDownvotes(userID: HashedUserID): Promise<boolean> {
|
||||||
|
const result = await db.prepare("get", `SELECT count(*) as "submissionCount", SUM(CASE WHEN "votes" < 0 AND "views" > 5 THEN 1 ELSE 0 END) AS "downvotedSubmissions" FROM "sponsorTimes" WHERE "userID" = ?`
|
||||||
|
, [userID], { useReplica: true });
|
||||||
|
|
||||||
|
return result.submissionCount > 100 && result.downvotedSubmissions / result.submissionCount < 0.15;
|
||||||
|
}
|
||||||
|
|
||||||
export async function canSubmit(userID: HashedUserID, category: Category): Promise<CanSubmitResult> {
|
export async function canSubmit(userID: HashedUserID, category: Category): Promise<CanSubmitResult> {
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case "chapter":
|
case "chapter":
|
||||||
return {
|
return {
|
||||||
canSubmit: await oneOf([isUserVIP(userID),
|
canSubmit: await oneOf([isUserVIP(userID),
|
||||||
|
lowDownvotes(userID),
|
||||||
(async () => (await getReputation(userID)) > config.minReputationToSubmitChapter)(),
|
(async () => (await getReputation(userID)) > config.minReputationToSubmitChapter)(),
|
||||||
hasFeature(userID, Feature.ChapterSubmitter)
|
hasFeature(userID, Feature.ChapterSubmitter)
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user