mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 16:37:12 +03:00
disallow vote types 10/11
This commit is contained in:
@@ -289,6 +289,13 @@ export async function voteOnSponsorTime(req: Request, res: Response) {
|
|||||||
//check if user voting on own submission
|
//check if user voting on own submission
|
||||||
const isOwnSubmission = (await db.prepare("get", `SELECT "UUID" as "submissionCount" FROM "sponsorTimes" where "userID" = ? AND "UUID" = ?`, [nonAnonUserID, UUID])) !== undefined;
|
const isOwnSubmission = (await db.prepare("get", `SELECT "UUID" as "submissionCount" FROM "sponsorTimes" where "userID" = ? AND "UUID" = ?`, [nonAnonUserID, UUID])) !== undefined;
|
||||||
|
|
||||||
|
// disallow vote types 10/11
|
||||||
|
if (type === 10 || type === 11) {
|
||||||
|
// no longer allow type 10/11 alternative votes
|
||||||
|
res.sendStatus(400)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If not upvote
|
// If not upvote
|
||||||
if (!isVIP && type !== 1) {
|
if (!isVIP && type !== 1) {
|
||||||
const isSegmentLocked = async () => !!(await db.prepare('get', `SELECT "locked" FROM "sponsorTimes" WHERE "UUID" = ?`, [UUID]))?.locked;
|
const isSegmentLocked = async () => !!(await db.prepare('get', `SELECT "locked" FROM "sponsorTimes" WHERE "UUID" = ?`, [UUID]))?.locked;
|
||||||
@@ -343,10 +350,10 @@ export async function voteOnSponsorTime(req: Request, res: Response) {
|
|||||||
let incrementAmount = 0;
|
let incrementAmount = 0;
|
||||||
let oldIncrementAmount = 0;
|
let oldIncrementAmount = 0;
|
||||||
|
|
||||||
if (type == 1 || type == 11) {
|
if (type == 1) {
|
||||||
//upvote
|
//upvote
|
||||||
incrementAmount = 1;
|
incrementAmount = 1;
|
||||||
} else if (type == 0 || type == 10) {
|
} else if (type == 0) {
|
||||||
//downvote
|
//downvote
|
||||||
incrementAmount = -1;
|
incrementAmount = -1;
|
||||||
} else if (type == 20) {
|
} else if (type == 20) {
|
||||||
@@ -358,10 +365,10 @@ export async function voteOnSponsorTime(req: Request, res: Response) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (votesRow != undefined) {
|
if (votesRow != undefined) {
|
||||||
if (votesRow.type === 1 || type === 11) {
|
if (votesRow.type === 1) {
|
||||||
//upvote
|
//upvote
|
||||||
oldIncrementAmount = 1;
|
oldIncrementAmount = 1;
|
||||||
} else if (votesRow.type === 0 || type === 10) {
|
} else if (votesRow.type === 0) {
|
||||||
//downvote
|
//downvote
|
||||||
oldIncrementAmount = -1;
|
oldIncrementAmount = -1;
|
||||||
} else if (votesRow.type === 2) {
|
} else if (votesRow.type === 2) {
|
||||||
|
|||||||
@@ -518,4 +518,22 @@ describe('voteOnSponsorTime', () => {
|
|||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should not be able to vote with type 10', (done: Done) => {
|
||||||
|
fetch(getbaseURL() + "/api/voteOnSponsorTime?userID=VIPUser&UUID=segment-locking-uuid-1&type=10")
|
||||||
|
.then(res => {
|
||||||
|
if (res.status !== 400) done('non 400 (' + res.status + ')');
|
||||||
|
else done(); // pass
|
||||||
|
})
|
||||||
|
.catch(err => done('couldn\'t call endpoint'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should not be able to vote with type 11', (done: Done) => {
|
||||||
|
fetch(getbaseURL() + "/api/voteOnSponsorTime?userID=VIPUser&UUID=segment-locking-uuid-1&type=11")
|
||||||
|
.then(res => {
|
||||||
|
if (res.status !== 400) done('non 400 (' + res.status + ')');
|
||||||
|
else done(); // pass
|
||||||
|
})
|
||||||
|
.catch(err => done('couldn\'t call endpoint'));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user