diff --git a/DatabaseSchema.md b/DatabaseSchema.md index 29b4c9bc..5752a532 100644 --- a/DatabaseSchema.md +++ b/DatabaseSchema.md @@ -322,6 +322,8 @@ | shadowHidden | INTEGER | not null, default 0 | | downvotes | INTEGER | default 0 | | removed | INTEGER | default 0 | +| createdAt | INTEGER | not null | +| updatedAt | INTEGER | not null | | constraint | field | | -- | :--: | diff --git a/databases/_upgrade_sponsorTimes_41.sql b/databases/_upgrade_sponsorTimes_41.sql index 8b35233c..3e62b4b8 100644 --- a/databases/_upgrade_sponsorTimes_41.sql +++ b/databases/_upgrade_sponsorTimes_41.sql @@ -23,6 +23,10 @@ ALTER TABLE "lockCategories" ADD "updatedAt" INTEGER NOT NULL; ALTER TABLE "titleVotes" ADD "createdAt" INTEGER NOT NULL; ALTER TABLE "titleVotes" ADD "updatedAt" INTEGER NOT NULL; +-- thumbnailVotes +ALTER TABLE "thumbnailVotes" ADD "createdAt" INTEGER NOT NULL; +ALTER TABLE "thumbnailVotes" ADD "updatedAt" INTEGER NOT NULL; + UPDATE "config" SET value = 41 WHERE key = 'version'; COMMIT; \ No newline at end of file diff --git a/src/routes/postBranding.ts b/src/routes/postBranding.ts index ebb0d142..abb1f741 100644 --- a/src/routes/postBranding.ts +++ b/src/routes/postBranding.ts @@ -145,8 +145,8 @@ export async function postBranding(req: Request, res: Response) { await db.prepare("run", `INSERT INTO "thumbnails" ("videoID", "original", "userID", "service", "hashedVideoID", "timeSubmitted", "UUID") VALUES (?, ?, ?, ?, ?, ?, ?)`, [videoID, thumbnail.original ? 1 : 0, hashedUserID, service, hashedVideoID, now, UUID]); - await db.prepare("run", `INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden") VALUES (?, 0, ?, ?)`, - [UUID, shouldLock ? 1 : 0, isBanned ? 1 : 0]); + await db.prepare("run", `INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden", "createdAt", "updatedAt") VALUES (?, 0, ?, ?, ?, ?)`, + [UUID, shouldLock ? 1 : 0, isBanned ? 1 : 0, now, now]); if (!thumbnail.original) { await db.prepare("run", `INSERT INTO "thumbnailTimestamps" ("UUID", "timestamp") VALUES (?, ?)`, @@ -156,7 +156,7 @@ export async function postBranding(req: Request, res: Response) { if (isVip && !downvote && shouldLock) { // unlock all other titles - 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]); + await db.prepare("run", `UPDATE "thumbnailVotes" as tv SET "locked" = 0, "updatedAt" = ? FROM "thumbnails" t WHERE tv."UUID" = t."UUID" AND tv."UUID" != ? AND t."videoID" = ?`, [now, UUID, videoID]); } } })()]); diff --git a/src/routes/shadowBanUser.ts b/src/routes/shadowBanUser.ts index d776398a..a52a0fb7 100644 --- a/src/routes/shadowBanUser.ts +++ b/src/routes/shadowBanUser.ts @@ -113,8 +113,8 @@ async function unHideSubmissionsByUser(categories: string[], deArrowTypes: DeArr } if (deArrowTypes.includes("thumbnail")) { - await db.prepare("run", `UPDATE "thumbnailVotes" as tv SET "shadowHidden" = ${type} FROM "thumbnails" t WHERE tv."UUID" = t."UUID" AND t."userID" = ?`, - [userID]); + await db.prepare("run", `UPDATE "thumbnailVotes" as tv SET "shadowHidden" = ${type}, "updatedAt" = ? FROM "thumbnails" t WHERE tv."UUID" = t."UUID" AND t."userID" = ?`, + [currentTime, userID]); } (await db.prepare("all", `SELECT "videoID", "hashedVideoID", "service" FROM "titles" WHERE "userID" = ?`, [userID]))