From 6f0abddd3e2096709d310f7c1eede0962e466993 Mon Sep 17 00:00:00 2001 From: Ajay Date: Fri, 28 Apr 2023 14:15:18 -0400 Subject: [PATCH] Reenable locks --- src/routes/postBranding.ts | 7 +++---- test/cases/postBranding.ts | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/routes/postBranding.ts b/src/routes/postBranding.ts index 0838057..541b3f4 100644 --- a/src/routes/postBranding.ts +++ b/src/routes/postBranding.ts @@ -38,8 +38,7 @@ export async function postBranding(req: Request, res: Response) { try { const hashedUserID = await getHashCache(userID); - // const isVip = await isUserVIP(hashedUserID); - const isVip = false; // TODO: In future, reenable locks + const isVip = await isUserVIP(hashedUserID); const hashedVideoID = await getHashCache(videoID, 1); const hashedIP = await getHashCache(getIP(req) + config.globalSalt as IPAddress); @@ -64,7 +63,7 @@ export async function postBranding(req: Request, res: Response) { if (isVip) { // unlock all other titles - await db.prepare("run", `UPDATE "titleVotes" SET "locked" = 0 WHERE "UUID" != ? AND "videoID" = ?`, [UUID, videoID]); + await db.prepare("run", `UPDATE "titleVotes" SET "locked" = 0 FROM "titles" WHERE "titleVotes"."UUID" != ? AND "titles"."UUID" != ? AND "titles"."videoID" = ?`, [UUID, UUID, videoID]); } } })(), (async () => { @@ -92,7 +91,7 @@ export async function postBranding(req: Request, res: Response) { if (isVip) { // unlock all other titles - await db.prepare("run", `UPDATE "thumbnailVotes" SET "locked" = 0 WHERE "UUID" != ? AND "videoID" = ?`, [UUID, videoID]); + await db.prepare("run", `UPDATE "thumbnailVotes" SET "locked" = 0 FROM "thumbnails" WHERE "thumbnailVotes"."UUID" != ? AND "thumbnails"."UUID" != ? AND "thumbnails"."videoID" = ?`, [UUID, UUID, videoID]); } } } diff --git a/test/cases/postBranding.ts b/test/cases/postBranding.ts index e34bfe8..36b878a 100644 --- a/test/cases/postBranding.ts +++ b/test/cases/postBranding.ts @@ -177,7 +177,7 @@ describe("postBranding", () => { assert.strictEqual(dbThumbnailVotes.shadowHidden, 0); }); - xit("Submit title and thumbnail as VIP", async () => { + it("Submit title and thumbnail as VIP", async () => { const videoID = "postBrand6"; const title = { title: "Some title", @@ -218,7 +218,7 @@ describe("postBranding", () => { assert.strictEqual(dbThumbnailVotes.shadowHidden, 0); }); - xit("Submit another title and thumbnail as VIP unlocks others", async () => { + it("Submit another title and thumbnail as VIP unlocks others", async () => { const videoID = "postBrand6"; const title = { title: "Some other title",