mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Fix act as vip unlocking segments
This commit is contained in:
parent
a921085da6
commit
47c109f012
2 changed files with 18 additions and 18 deletions
|
@ -104,13 +104,9 @@ export async function postBranding(req: Request, res: Response) {
|
|||
await verifyOldSubmissions(hashedUserID, verificationValue);
|
||||
}
|
||||
|
||||
if (isVip && !downvote) {
|
||||
if (isVip && !downvote && shouldLock) {
|
||||
// unlock all other titles
|
||||
if (shouldLock) {
|
||||
await db.prepare("run", `UPDATE "titleVotes" as tv SET "locked" = 0 FROM "titles" t WHERE tv."UUID" = t."UUID" AND tv."UUID" != ? AND t."videoID" = ?`, [UUID, videoID]);
|
||||
} else {
|
||||
await db.prepare("run", `UPDATE "titleVotes" as tv SET "locked" = 0 FROM "titles" t WHERE tv."UUID" = t."UUID" AND t."videoID" = ?`, [videoID]);
|
||||
}
|
||||
await db.prepare("run", `UPDATE "titleVotes" as tv SET "locked" = 0 FROM "titles" t WHERE tv."UUID" = t."UUID" AND tv."UUID" != ? AND t."videoID" = ?`, [UUID, videoID]);
|
||||
}
|
||||
|
||||
sendWebhooks(videoID, UUID).catch((e) => Logger.error(e));
|
||||
|
@ -152,13 +148,9 @@ export async function postBranding(req: Request, res: Response) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isVip && !downvote) {
|
||||
if (isVip && !downvote && shouldLock) {
|
||||
// unlock all other titles
|
||||
if (shouldLock) {
|
||||
await db.prepare("run", `UPDATE "thumbnailVotes" as tv SET "locked" = 0 FROM "thumbnails" t WHERE tv."UUID" = t."UUID" AND tv."UUID" != ? AND t."videoID" = ?`, [UUID, videoID]);
|
||||
} else {
|
||||
await db.prepare("run", `UPDATE "thumbnailVotes" as tv SET "locked" = 0 FROM "thumbnails" t WHERE tv."UUID" = t."UUID" AND t."videoID" = ?`, [videoID]);
|
||||
}
|
||||
await db.prepare("run", `UPDATE "thumbnailVotes" as tv SET "locked" = 0 FROM "thumbnails" t WHERE tv."UUID" = t."UUID" AND tv."UUID" != ? AND t."videoID" = ?`, [UUID, videoID]);
|
||||
}
|
||||
}
|
||||
})()]);
|
||||
|
|
|
@ -614,13 +614,21 @@ describe("postBranding", () => {
|
|||
});
|
||||
|
||||
assert.strictEqual(res.status, 200);
|
||||
const dbTitle = await queryTitleByVideo(videoID);
|
||||
const dbTitleVotes = await queryTitleVotesByUUID(dbTitle.UUID);
|
||||
const dbThumbnail = await queryThumbnailByVideo(videoID);
|
||||
const dbThumbnailVotes = await queryThumbnailVotesByUUID(dbThumbnail.UUID);
|
||||
const dbTitles = await queryTitleByVideo(videoID, true);
|
||||
for (const dbTitle of dbTitles) {
|
||||
if (dbTitle.title === title.title) {
|
||||
const dbTitleVotes = await queryTitleVotesByUUID(dbTitle.UUID);
|
||||
assert.strictEqual(dbTitleVotes.locked, 0);
|
||||
}
|
||||
}
|
||||
|
||||
assert.strictEqual(dbTitleVotes.locked, 0);
|
||||
assert.strictEqual(dbThumbnailVotes.locked, 0);
|
||||
const dbThumbnails = await queryThumbnailByVideo(videoID, true);
|
||||
for (const dbThumbnail of dbThumbnails) {
|
||||
if (dbThumbnail.timestamp === thumbnail.timestamp) {
|
||||
const dbThumbnailVotes = await queryThumbnailVotesByUUID(dbThumbnail.UUID);
|
||||
assert.strictEqual(dbThumbnailVotes.locked, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("Downvote title and thumbnail as VIP", async () => {
|
||||
|
|
Loading…
Reference in a new issue