mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 11:36:58 +03:00
Fix VIP title and thumbnail unlock unlocking everything
This commit is contained in:
@@ -63,7 +63,7 @@ export async function postBranding(req: Request, res: Response) {
|
|||||||
|
|
||||||
if (isVip) {
|
if (isVip) {
|
||||||
// unlock all other titles
|
// unlock all other titles
|
||||||
await db.prepare("run", `UPDATE "titleVotes" SET "locked" = 0 FROM "titles" WHERE "titleVotes"."UUID" != ? AND "titles"."UUID" != ? AND "titles"."videoID" = ?`, [UUID, UUID, 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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})(), (async () => {
|
})(), (async () => {
|
||||||
@@ -91,7 +91,7 @@ export async function postBranding(req: Request, res: Response) {
|
|||||||
|
|
||||||
if (isVip) {
|
if (isVip) {
|
||||||
// unlock all other titles
|
// unlock all other titles
|
||||||
await db.prepare("run", `UPDATE "thumbnailVotes" SET "locked" = 0 FROM "thumbnails" WHERE "thumbnailVotes"."UUID" != ? AND "thumbnails"."UUID" != ? AND "thumbnails"."videoID" = ?`, [UUID, UUID, 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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,20 @@ describe("postBranding", () => {
|
|||||||
const insertVipUserQuery = 'INSERT INTO "vipUsers" ("userID") VALUES (?)';
|
const insertVipUserQuery = 'INSERT INTO "vipUsers" ("userID") VALUES (?)';
|
||||||
db.prepare("run", insertVipUserQuery, [getHash(vipUser)]);
|
db.prepare("run", insertVipUserQuery, [getHash(vipUser)]);
|
||||||
db.prepare("run", insertVipUserQuery, [getHash(vipUser2)]);
|
db.prepare("run", insertVipUserQuery, [getHash(vipUser2)]);
|
||||||
|
|
||||||
|
const insertTitleQuery = 'INSERT INTO "titles" ("videoID", "title", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID") VALUES (?, ?, ?, ?, ?, ?, ?, ?)';
|
||||||
|
db.prepare("run", insertTitleQuery, ["postBrandLocked1", "Some title", 0, getHash(userID1), Service.YouTube, getHash("postBrandLocked1"), Date.now(), "postBrandLocked1"]);
|
||||||
|
db.prepare("run", insertTitleQuery, ["postBrandLocked2", "Some title", 1, getHash(userID2), Service.YouTube, getHash("postBrandLocked2"), Date.now(), "postBrandLocked2"]);
|
||||||
|
const insertTitleVotesQuery = 'INSERT INTO "titleVotes" ("UUID", "votes", "locked", "shadowHidden") VALUES (?, ?, ?, ?);';
|
||||||
|
db.prepare("run", insertTitleVotesQuery, ["postBrandLocked1", 0, 1, 0]);
|
||||||
|
db.prepare("run", insertTitleVotesQuery, ["postBrandLocked2", 0, 1, 0]);
|
||||||
|
|
||||||
|
const insertThumbnailQuery = 'INSERT INTO "thumbnails" ("videoID", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID") VALUES (?, ?, ?, ?, ?, ?, ?)';
|
||||||
|
db.prepare("run", insertThumbnailQuery, ["postBrandLocked1", 0, getHash(userID3), Service.YouTube, getHash("postBrandLocked1"), Date.now(), "postBrandLocked1"]);
|
||||||
|
db.prepare("run", insertThumbnailQuery, ["postBrandLocked2", 1, getHash(userID4), Service.YouTube, getHash("postBrandLocked2"), Date.now(), "postBrandLocked2"]);
|
||||||
|
const insertThumbnailVotesQuery = 'INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden") VALUES (?, ?, ?, ?);';
|
||||||
|
db.prepare("run", insertThumbnailVotesQuery, ["postBrandLocked1", 0, 1, 0]);
|
||||||
|
db.prepare("run", insertThumbnailVotesQuery, ["postBrandLocked2", 0, 1, 0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Submit only title", async () => {
|
it("Submit only title", async () => {
|
||||||
@@ -261,6 +275,17 @@ describe("postBranding", () => {
|
|||||||
assert.strictEqual(dbThumbnailVotes.locked, 1);
|
assert.strictEqual(dbThumbnailVotes.locked, 1);
|
||||||
assert.strictEqual(dbThumbnailVotes.shadowHidden, 0);
|
assert.strictEqual(dbThumbnailVotes.shadowHidden, 0);
|
||||||
assert.strictEqual(dbThumbnailVotesOld.locked, 0);
|
assert.strictEqual(dbThumbnailVotesOld.locked, 0);
|
||||||
|
|
||||||
|
const otherSegmentTitleVotes1 = await queryTitleVotesByUUID("postBrandLocked1");
|
||||||
|
const otherSegmentTitleVotes2 = await queryTitleVotesByUUID("postBrandLocked2");
|
||||||
|
const otherSegmentThumbnailVotes1 = await queryThumbnailVotesByUUID("postBrandLocked1");
|
||||||
|
const otherSegmentThumbnailVotes2 = await queryThumbnailVotesByUUID("postBrandLocked2");
|
||||||
|
|
||||||
|
// They should remain locked
|
||||||
|
assert.strictEqual(otherSegmentTitleVotes1.locked, 1);
|
||||||
|
assert.strictEqual(otherSegmentTitleVotes2.locked, 1);
|
||||||
|
assert.strictEqual(otherSegmentThumbnailVotes1.locked, 1);
|
||||||
|
assert.strictEqual(otherSegmentThumbnailVotes2.locked, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Vote the same title again", async () => {
|
it("Vote the same title again", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user