Unlock other segments when vip votes for new segment

This commit is contained in:
Ajay
2023-02-14 22:10:46 -05:00
parent 9cf2e1f0e9
commit 46c372a764
2 changed files with 62 additions and 5 deletions

View File

@@ -59,6 +59,11 @@ export async function postBranding(req: Request, res: Response) {
await db.prepare("run", `INSERT INTO "titleVotes" ("UUID", "votes", "locked", "shadowHidden") VALUES (?, 0, ?, 0);`,
[UUID, isVip ? 1 : 0]);
}
if (isVip) {
// unlock all other titles
await db.prepare("run", `UPDATE "titleVotes" SET "locked" = 0 WHERE "UUID" != ?`, [UUID]);
}
}
})(), (async () => {
if (thumbnail) {
@@ -82,6 +87,11 @@ export async function postBranding(req: Request, res: Response) {
await db.prepare("run", `INSERT INTO "thumbnailTimestamps" ("UUID", "timestamp") VALUES (?, ?)`,
[UUID, (thumbnail as TimeThumbnailSubmission).timestamp]);
}
if (isVip) {
// unlock all other titles
await db.prepare("run", `UPDATE "thumbnailVotes" SET "locked" = 0 WHERE "UUID" != ?`, [UUID]);
}
}
}
})()]);