mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Add DeArrow submitter feature
This commit is contained in:
parent
9d1af3bdff
commit
0723503a98
3 changed files with 9 additions and 5 deletions
|
@ -19,11 +19,13 @@ interface AddFeatureRequest extends Request {
|
||||||
const allowedFeatures = {
|
const allowedFeatures = {
|
||||||
vip: [
|
vip: [
|
||||||
Feature.ChapterSubmitter,
|
Feature.ChapterSubmitter,
|
||||||
Feature.FillerSubmitter
|
Feature.FillerSubmitter,
|
||||||
|
Feature.DeArrowTitleSubmitter,
|
||||||
],
|
],
|
||||||
admin: [
|
admin: [
|
||||||
Feature.ChapterSubmitter,
|
Feature.ChapterSubmitter,
|
||||||
Feature.FillerSubmitter
|
Feature.FillerSubmitter,
|
||||||
|
Feature.DeArrowTitleSubmitter,
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { db, privateDB } from "../databases/databases";
|
||||||
|
|
||||||
import { BrandingSubmission, BrandingUUID, TimeThumbnailSubmission } from "../types/branding.model";
|
import { BrandingSubmission, BrandingUUID, TimeThumbnailSubmission } from "../types/branding.model";
|
||||||
import { HashedIP, IPAddress, VideoID } from "../types/segments.model";
|
import { HashedIP, IPAddress, VideoID } from "../types/segments.model";
|
||||||
import { HashedUserID } from "../types/user.model";
|
import { Feature, HashedUserID } from "../types/user.model";
|
||||||
import { getHashCache } from "../utils/getHashCache";
|
import { getHashCache } from "../utils/getHashCache";
|
||||||
import { getIP } from "../utils/getIP";
|
import { getIP } from "../utils/getIP";
|
||||||
import { getService } from "../utils/getService";
|
import { getService } from "../utils/getService";
|
||||||
|
@ -13,6 +13,7 @@ import { Logger } from "../utils/logger";
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
import { QueryCacher } from "../utils/queryCacher";
|
import { QueryCacher } from "../utils/queryCacher";
|
||||||
import { acquireLock } from "../utils/redisLock";
|
import { acquireLock } from "../utils/redisLock";
|
||||||
|
import { hasFeature } from "../utils/features";
|
||||||
|
|
||||||
enum BrandingType {
|
enum BrandingType {
|
||||||
Title,
|
Title,
|
||||||
|
@ -166,7 +167,7 @@ async function getVerificationValue(hashedUserID: HashedUserID, isVip: boolean):
|
||||||
const voteSum = await db.prepare("get", `SELECT SUM("maxVotes") as "voteSum" FROM (SELECT MAX("votes") as "maxVotes" from "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID" WHERE "titles"."userID" = ? GROUP BY "titles"."videoID") t`, [hashedUserID]);
|
const voteSum = await db.prepare("get", `SELECT SUM("maxVotes") as "voteSum" FROM (SELECT MAX("votes") as "maxVotes" from "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID" WHERE "titles"."userID" = ? GROUP BY "titles"."videoID") t`, [hashedUserID]);
|
||||||
const sbSubmissions = () => db.prepare("get", `SELECT COUNT(*) as count FROM "sponsorTimes" WHERE "userID" = ? AND "votes" > 0 LIMIT 3`, [hashedUserID]);
|
const sbSubmissions = () => db.prepare("get", `SELECT COUNT(*) as count FROM "sponsorTimes" WHERE "userID" = ? AND "votes" > 0 LIMIT 3`, [hashedUserID]);
|
||||||
|
|
||||||
if (voteSum.voteSum >= 1 || isVip || (await sbSubmissions()).count > 2) {
|
if (voteSum.voteSum >= 1 || isVip || (await sbSubmissions()).count > 2 || await hasFeature(hashedUserID, Feature.DeArrowTitleSubmitter)) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -5,5 +5,6 @@ export type HashedUserID = UserID & HashedValue;
|
||||||
|
|
||||||
export enum Feature {
|
export enum Feature {
|
||||||
ChapterSubmitter = 0,
|
ChapterSubmitter = 0,
|
||||||
FillerSubmitter = 1
|
FillerSubmitter = 1,
|
||||||
|
DeArrowTitleSubmitter = 2,
|
||||||
}
|
}
|
Loading…
Reference in a new issue