mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
Unlock segment if VIP downvotes
This commit is contained in:
parent
e21ebd18a6
commit
597dff7ac3
2 changed files with 21 additions and 0 deletions
|
@ -378,6 +378,9 @@ export async function voteOnSponsorTime(req: Request, res: Response) {
|
||||||
if (isVIP && incrementAmount > 0 && voteTypeEnum === voteTypes.normal) {
|
if (isVIP && incrementAmount > 0 && voteTypeEnum === voteTypes.normal) {
|
||||||
// Lock this submission
|
// Lock this submission
|
||||||
db.prepare('run', "UPDATE sponsorTimes SET locked = 1 WHERE UUID = ?", [UUID]);
|
db.prepare('run', "UPDATE sponsorTimes SET locked = 1 WHERE UUID = ?", [UUID]);
|
||||||
|
} else if (isVIP && incrementAmount < 0 && voteTypeEnum === voteTypes.normal) {
|
||||||
|
// Unlock if a VIP downvotes it
|
||||||
|
db.prepare('run', "UPDATE sponsorTimes SET locked = 0 WHERE UUID = ?", [UUID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//for each positive vote, see if a hidden submission can be shown again
|
//for each positive vote, see if a hidden submission can be shown again
|
||||||
|
|
|
@ -465,4 +465,22 @@ describe('voteOnSponsorTime', () => {
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('VIP downvote should unlock segment', (done: Done) => {
|
||||||
|
fetch(getbaseURL()
|
||||||
|
+ "/api/voteOnSponsorTime?userID=VIPUser&UUID=segment-locking-uuid-1&type=0")
|
||||||
|
.then(res => {
|
||||||
|
if (res.status === 200) {
|
||||||
|
let row = db.prepare('get', "SELECT locked FROM sponsorTimes WHERE UUID = ?", ["segment-locking-uuid-1"]);
|
||||||
|
if (!row?.locked) {
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
done("Segment not locked");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
done("Status code was " + res.status + " instead of 200");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => done(err));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue