don't allow category vote for full video segment

This commit is contained in:
Ajay
2022-01-14 00:21:13 -05:00
parent 762f4f6964
commit 6fe7200481
2 changed files with 51 additions and 36 deletions

View File

@@ -1,4 +1,4 @@
import { Request, Response } from "express";
import e, { Request, Response } from "express";
import { Logger } from "../utils/logger";
import { isUserVIP } from "../utils/isUserVIP";
import { getMaxResThumbnail, YouTubeAPI } from "../utils/youtubeApi";
@@ -197,13 +197,17 @@ async function categoryVote(UUID: SegmentUUID, userID: UserID, isVIP: boolean, i
return { status: finalResponse.finalStatus };
}
const videoInfo = (await db.prepare("get", `SELECT "category", "videoID", "hashedVideoID", "service", "userID", "locked" FROM "sponsorTimes" WHERE "UUID" = ?`,
[UUID])) as {category: Category, videoID: VideoID, hashedVideoID: VideoIDHash, service: Service, userID: UserID, locked: number};
const videoInfo = (await db.prepare("get", `SELECT "category", "actionType", "videoID", "hashedVideoID", "service", "userID", "locked" FROM "sponsorTimes" WHERE "UUID" = ?`,
[UUID])) as {category: Category, actionType: ActionType, videoID: VideoID, hashedVideoID: VideoIDHash, service: Service, userID: UserID, locked: number};
if (!videoInfo) {
// Submission doesn't exist
return { status: 400, message: "Submission doesn't exist." };
}
if (videoInfo.actionType === ActionType.Full) {
return { status: 400, message: "Not allowed to change category of a full video segment" };
}
if (!config.categoryList.includes(category)) {
return { status: 400, message: "Category doesn't exist." };
}