Don't allow votes on locked videos

This commit is contained in:
Ajay Ramachandran
2020-12-16 22:53:49 -05:00
parent 9797d7450c
commit cd373f4bca
2 changed files with 69 additions and 0 deletions

View File

@@ -234,6 +234,18 @@ async function voteOnSponsorTime(req: Request, res: Response) {
//check if user voting on own submission
const isOwnSubmission = db.prepare("get", "SELECT UUID as submissionCount FROM sponsorTimes where userID = ? AND UUID = ?", [nonAnonUserID, UUID]) !== undefined;
if (!isVIP) {
const isVideoLocked = !!db.prepare('get', 'SELECT noSegments.category from noSegments left join sponsorTimes' +
' on (noSegments.videoID = sponsorTimes.videoID and noSegments.category = sponsorTimes.category)' +
' where UUID = ?', [UUID]);
if (isVideoLocked) {
res.status(403).send("Not allowed to vote on video that has been locked by a VIP.");
return;
}
}
if (type === undefined && category !== undefined) {
return categoryVote(UUID, nonAnonUserID, isVIP, category, hashedIP, res);
}