Add DeArrow submitter feature

This commit is contained in:
Ajay 2023-08-04 14:17:41 -04:00
parent 9d1af3bdff
commit 0723503a98
3 changed files with 9 additions and 5 deletions

View file

@ -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,
] ]
}; };

View file

@ -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;

View file

@ -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,
} }