mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-14 15:37:07 +03:00
Prevent voting for highlight category
This commit is contained in:
@@ -170,6 +170,10 @@ async function categoryVote(UUID: SegmentUUID, userID: UserID, isVIP: boolean, i
|
||||
res.status(400).send("Category doesn't exist.");
|
||||
return;
|
||||
}
|
||||
if (category === "highlight") {
|
||||
res.status(400).send("Cannot vote for this category");
|
||||
return;
|
||||
}
|
||||
|
||||
const nextCategoryInfo = await db.prepare("get", `select votes from "categoryVotes" where "UUID" = ? and category = ?`, [UUID, category]);
|
||||
|
||||
|
||||
@@ -264,6 +264,24 @@ describe('voteOnSponsorTime', () => {
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it('Should not able to change to highlight category', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=incorrect-category&category=highlight")
|
||||
.then(async res => {
|
||||
if (res.status === 400) {
|
||||
let row = await db.prepare('get', `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, ["incorrect-category"]);
|
||||
if (row.category === "sponsor") {
|
||||
done();
|
||||
} else {
|
||||
done("Vote did not succeed. Submission went from sponsor to " + row.category);
|
||||
}
|
||||
} else {
|
||||
done("Status code was " + res.status);
|
||||
}
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it('Should be able to change your vote for a category and it should add your vote to the database', (done: Done) => {
|
||||
fetch(getbaseURL()
|
||||
+ "/api/voteOnSponsorTime?userID=randomID2&UUID=vote-uuid-4&category=outro")
|
||||
|
||||
Reference in New Issue
Block a user