refactor: change isoTimestamp to isoDate

This commit is contained in:
Tristan 2024-09-16 19:24:54 +02:00
parent 829fd5dc18
commit a701486cbd
10 changed files with 47 additions and 47 deletions

View file

@ -38,11 +38,11 @@ export async function addUserAsVIP(req: AddUserAsVIPRequest, res: Response): Pro
try {
if (enabled && !userIsVIP) {
// add them to the vip list
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
await db.prepare(
"run",
'INSERT INTO "vipUsers" ("userID", "createdAt") VALUES(?, ?)',
[userID, isoTimestamp]
[userID, isoDate]
);
}

View file

@ -67,7 +67,7 @@ export async function postBranding(req: Request, res: Response) {
}
const now = Date.now();
const isoTimestamp = new Date(now).toISOString();
const isoDate = new Date(now).toISOString();
const voteType: BrandingVoteType = downvote ? BrandingVoteType.Downvote : BrandingVoteType.Upvote;
if (title && !isVip && title.title.length > config.maxTitleLength) {
@ -106,14 +106,14 @@ export async function postBranding(req: Request, res: Response) {
const verificationValue = await getVerificationValue(hashedUserID, isVip);
await db.prepare("run", `INSERT INTO "titleVotes" ("UUID", "votes", "locked", "shadowHidden", "verification", "createdAt", "updatedAt") VALUES (?, 0, ?, ?, ?, ?, ?);`,
[UUID, shouldLock ? 1 : 0, isBanned ? 1 : 0, verificationValue, isoTimestamp, isoTimestamp]);
[UUID, shouldLock ? 1 : 0, isBanned ? 1 : 0, verificationValue, isoDate, isoDate]);
await verifyOldSubmissions(hashedUserID, verificationValue);
}
if (isVip && !downvote && shouldLock) {
// unlock all other titles
await db.prepare("run", `UPDATE "titleVotes" as tv SET "locked" = 0, "updatedAt" = ? FROM "titles" t WHERE tv."UUID" = t."UUID" AND tv."UUID" != ? AND t."videoID" = ?`, [isoTimestamp, UUID, videoID]);
await db.prepare("run", `UPDATE "titleVotes" as tv SET "locked" = 0, "updatedAt" = ? FROM "titles" t WHERE tv."UUID" = t."UUID" AND tv."UUID" != ? AND t."videoID" = ?`, [isoDate, UUID, videoID]);
}
sendWebhooks(videoID, UUID, voteType).catch((e) => Logger.error(e));
@ -147,7 +147,7 @@ export async function postBranding(req: Request, res: Response) {
[videoID, thumbnail.original ? 1 : 0, hashedUserID, service, hashedVideoID, now, UUID]);
await db.prepare("run", `INSERT INTO "thumbnailVotes" ("UUID", "votes", "locked", "shadowHidden", "createdAt", "updatedAt") VALUES (?, 0, ?, ?, ?, ?)`,
[UUID, shouldLock ? 1 : 0, isBanned ? 1 : 0, isoTimestamp, isoTimestamp]);
[UUID, shouldLock ? 1 : 0, isBanned ? 1 : 0, isoDate, isoDate]);
if (!thumbnail.original) {
await db.prepare("run", `INSERT INTO "thumbnailTimestamps" ("UUID", "timestamp") VALUES (?, ?)`,
@ -157,7 +157,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, "updatedAt" = ? FROM "thumbnails" t WHERE tv."UUID" = t."UUID" AND tv."UUID" != ? AND t."videoID" = ?`, [isoTimestamp, 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" = ?`, [isoDate, UUID, videoID]);
}
}
})()]);
@ -285,7 +285,7 @@ export async function getVerificationValue(hashedUserID: HashedUserID, isVip: bo
export async function verifyOldSubmissions(hashedUserID: HashedUserID, verification: number): Promise<void> {
if (verification >= 0) {
const unverifiedSubmissions = await db.prepare("all", `SELECT "videoID", "hashedVideoID", "service" FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID" WHERE "titles"."userID" = ? AND "titleVotes"."verification" < ? GROUP BY "videoID", "hashedVideoID", "service"`, [hashedUserID, verification]);
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
if (unverifiedSubmissions.length > 0) {
for (const submission of unverifiedSubmissions) {
@ -296,7 +296,7 @@ export async function verifyOldSubmissions(hashedUserID: HashedUserID, verificat
});
}
await db.prepare("run", `UPDATE "titleVotes" as tv SET "verification" = ?, "updatedAt" = ? FROM "titles" WHERE "titles"."UUID" = tv."UUID" AND "titles"."userID" = ? AND tv."verification" < ?`, [verification, isoTimestamp, hashedUserID, verification]);
await db.prepare("run", `UPDATE "titleVotes" as tv SET "verification" = ?, "updatedAt" = ? FROM "titles" WHERE "titles"."UUID" = tv."UUID" AND "titles"."userID" = ? AND tv."verification" < ?`, [verification, isoDate, hashedUserID, verification]);
}
}
}

View file

@ -61,7 +61,7 @@ export async function postLockCategories(req: Request, res: Response): Promise<s
// calculate hash of videoID
const hashedVideoID: VideoIDHash = await getHashCache(videoID, 1);
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
// create database entry
for (const lock of locksToApply) {
@ -69,7 +69,7 @@ export async function postLockCategories(req: Request, res: Response): Promise<s
await db.prepare(
"run",
`INSERT INTO "lockCategories" ("videoID", "userID", "actionType", "category", "hashedVideoID", "reason", "service", "createdAt", "updatedAt") VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)`,
[videoID, userID, lock.actionType, lock.category, hashedVideoID, reason, service, isoTimestamp, isoTimestamp]
[videoID, userID, lock.actionType, lock.category, hashedVideoID, reason, service, isoDate, isoDate]
);
} catch (err) /* istanbul ignore next */ {
Logger.error(`Error submitting 'lockCategories' marker for category '${lock.category}' and actionType '${lock.actionType}' for video '${videoID}' (${service})`);
@ -86,7 +86,7 @@ export async function postLockCategories(req: Request, res: Response): Promise<s
try {
await db.prepare("run",
'UPDATE "lockCategories" SET "reason" = ?, "userID" = ?, "updatedAt" = ? WHERE "videoID" = ? AND "actionType" = ? AND "category" = ? AND "service" = ?',
[reason, userID, isoTimestamp, videoID, lock.actionType, lock.category, service]);
[reason, userID, isoDate, videoID, lock.actionType, lock.category, service]);
} catch (err) /* istanbul ignore next */ {
Logger.error(`Error submitting 'lockCategories' marker for category '${lock.category}' and actionType '${lock.actionType}' for video '${videoID}' (${service})`);
Logger.error(err as string);

View file

@ -28,8 +28,8 @@ export async function postPurgeAllSegments(req: Request, res: Response): Promise
});
}
const isoTimestamp = new Date().toISOString();
await db.prepare("run", `UPDATE "sponsorTimes" SET "hidden" = 1, "updatedAt" = ? WHERE "videoID" = ?`, [isoTimestamp, videoID]);
const isoDate = new Date().toISOString();
await db.prepare("run", `UPDATE "sponsorTimes" SET "hidden" = 1, "updatedAt" = ? WHERE "videoID" = ?`, [isoDate, videoID]);
const hashedVideoID: VideoIDHash = await getHashCache(videoID, 1);
QueryCacher.clearSegmentCache({

View file

@ -79,20 +79,20 @@ export async function postSegmentShift(req: Request, res: Response): Promise<Res
startTime,
endTime,
};
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
for (const segment of segments) {
const result = shiftSegment(segment, shift);
switch (result.action) {
case ACTION_UPDATE:
await db.prepare("run", 'UPDATE "sponsorTimes" SET "startTime" = ?, "endTime" = ?, "updatedAt" = ? WHERE "UUID" = ?', [result.segment.startTime, result.segment.endTime, isoTimestamp, result.segment.UUID]);
await db.prepare("run", 'UPDATE "sponsorTimes" SET "startTime" = ?, "endTime" = ?, "updatedAt" = ? WHERE "UUID" = ?', [result.segment.startTime, result.segment.endTime, isoDate, result.segment.UUID]);
break;
case ACTION_REMOVE:
await db.prepare("run", 'UPDATE "sponsorTimes" SET "startTime" = ?, "endTime" = ?, "votes" = -2, "updatedAt" = ? WHERE "UUID" = ?', [result.segment.startTime, result.segment.endTime, isoTimestamp, result.segment.UUID]);
await db.prepare("run", 'UPDATE "sponsorTimes" SET "startTime" = ?, "endTime" = ?, "votes" = -2, "updatedAt" = ? WHERE "UUID" = ?', [result.segment.startTime, result.segment.endTime, isoDate, result.segment.UUID]);
break;
}
}
} catch (err) /* istanbul ignore next */ {
} catch (err) /* istanbul ignore next */ {
Logger.error(err as string);
return res.sendStatus(500);
}

View file

@ -392,14 +392,14 @@ async function updateDataIfVideoDurationChange(videoID: VideoID, service: Servic
// Only treat as difference if both the api duration and submitted duration have changed
if (videoDurationChanged(videoDuration) && (!videoDurationParam || videoDurationChanged(videoDurationParam))) {
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
// Hide all previous submissions
await db.prepare("run", `UPDATE "sponsorTimes" SET "hidden" = 1, "updatedAt" = ?
WHERE "videoID" = ? AND "service" = ? AND "videoDuration" != ?
AND "hidden" = 0 AND "shadowHidden" = 0 AND
"actionType" != 'full' AND "votes" > -2`,
[isoTimestamp, videoID, service, videoDuration]);
[isoDate, videoID, service, videoDuration]);
lockedCategoryList = [];
deleteLockCategories(videoID, null, null, service).catch((e) => Logger.error(`deleting lock categories: ${e}`));
@ -560,7 +560,7 @@ export async function postSkipSegments(req: Request, res: Response): Promise<Res
const hashedIP = await getHashCache(rawIP + config.globalSalt) as HashedIP;
const timeSubmitted = Date.now();
const isoTimestamp = new Date(timeSubmitted).toISOString();
const isoDate = new Date(timeSubmitted).toISOString();
// const rateLimitCheckResult = checkRateLimit(userID, videoID, service, timeSubmitted, hashedIP);
// if (!rateLimitCheckResult.pass) {
@ -592,7 +592,7 @@ export async function postSkipSegments(req: Request, res: Response): Promise<Res
("videoID", "startTime", "endTime", "votes", "locked", "UUID", "userID", "timeSubmitted", "views", "category", "actionType", "service", "videoDuration", "reputation", "shadowHidden", "hashedVideoID", "userAgent", "description", "updatedAt")
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
videoID, segmentInfo.segment[0], segmentInfo.segment[1], startingVotes, startingLocked, UUID, userID, timeSubmitted, 0
, segmentInfo.category, segmentInfo.actionType, service, videoDuration, reputation, isBanned ? 1 : 0, hashedVideoID, userAgent, segmentInfo.description, isoTimestamp
, segmentInfo.category, segmentInfo.actionType, service, videoDuration, reputation, isBanned ? 1 : 0, hashedVideoID, userAgent, segmentInfo.description, isoDate
],
);

View file

@ -6,7 +6,7 @@ import { Request, Response } from "express";
import { isUserBanned } from "../utils/checkBan";
import { HashedUserID } from "../types/user.model";
function logUserNameChange(userID: string, newUserName: string, oldUserName: string, updatedByAdmin: boolean): Promise<Response> {
function logUserNameChange(userID: string, newUserName: string, oldUserName: string, updatedByAdmin: boolean): Promise<Response> {
return privateDB.prepare("run",
`INSERT INTO "userNameLogs"("userID", "newUserName", "oldUserName", "updatedByAdmin", "updatedAt") VALUES(?, ?, ?, ?, ?)`,
[userID, newUserName, oldUserName, + updatedByAdmin, new Date().getTime()]
@ -79,7 +79,7 @@ export async function setUsername(req: Request, res: Response): Promise<Response
const row = await db.prepare("get", `SELECT "userName" FROM "userNames" WHERE "userID" = ? LIMIT 1`, [hashedUserID]);
const locked = adminUserIDInput === undefined ? 0 : 1;
let oldUserName = "";
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
timings.push(Date.now());
@ -89,11 +89,11 @@ export async function setUsername(req: Request, res: Response): Promise<Response
if (userName == hashedUserID && !locked) {
await db.prepare("run", `DELETE FROM "userNames" WHERE "userID" = ?`, [hashedUserID]);
} else {
await db.prepare("run", `UPDATE "userNames" SET "userName" = ?, "locked" = ?, "updatedAt" = ? WHERE "userID" = ?`, [userName, locked, isoTimestamp, hashedUserID]);
await db.prepare("run", `UPDATE "userNames" SET "userName" = ?, "locked" = ?, "updatedAt" = ? WHERE "userID" = ?`, [userName, locked, isoDate, hashedUserID]);
}
} else {
//add to the db
await db.prepare("run", `INSERT INTO "userNames"("userID", "userName", "locked", "createdAt", "updatedAt") VALUES(?, ?, ?, ?, ?)`, [hashedUserID, userName, locked, isoTimestamp, isoTimestamp]);
await db.prepare("run", `INSERT INTO "userNames"("userID", "userName", "locked", "createdAt", "updatedAt") VALUES(?, ?, ?, ?, ?)`, [hashedUserID, userName, locked, isoDate, isoDate]);
}
timings.push(Date.now());

View file

@ -93,12 +93,12 @@ export async function banUser(userID: UserID, enabled: boolean, unHideOldSubmiss
async function unHideSubmissionsByUser(categories: string[], deArrowTypes: DeArrowType[],
userID: UserID, type = 1) {
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
if (categories.length) {
await db.prepare("run", `UPDATE "sponsorTimes" SET "shadowHidden" = '${type}', "updatedAt = ? WHERE "userID" = ? AND "category" in (${categories.map((c) => `'${c}'`).join(",")})
AND NOT EXISTS ( SELECT "videoID", "category" FROM "lockCategories" WHERE
"sponsorTimes"."videoID" = "lockCategories"."videoID" AND "sponsorTimes"."service" = "lockCategories"."service" AND "sponsorTimes"."category" = "lockCategories"."category")`, [isoTimestamp, userID]);
"sponsorTimes"."videoID" = "lockCategories"."videoID" AND "sponsorTimes"."service" = "lockCategories"."service" AND "sponsorTimes"."category" = "lockCategories"."category")`, [isoDate, userID]);
}
// clear cache for all old videos
@ -109,12 +109,12 @@ async function unHideSubmissionsByUser(categories: string[], deArrowTypes: DeArr
if (deArrowTypes.includes("title")) {
await db.prepare("run", `UPDATE "titleVotes" as tv SET "shadowHidden" = ${type}, "updatedAt" = ? FROM "titles" t WHERE tv."UUID" = t."UUID" AND t."userID" = ?`,
[isoTimestamp, userID]);
[isoDate, userID]);
}
if (deArrowTypes.includes("thumbnail")) {
await db.prepare("run", `UPDATE "thumbnailVotes" as tv SET "shadowHidden" = ${type}, "updatedAt" = ? FROM "thumbnails" t WHERE tv."UUID" = t."UUID" AND t."userID" = ?`,
[isoTimestamp, userID]);
[isoDate, userID]);
}
(await db.prepare("all", `SELECT "videoID", "hashedVideoID", "service" FROM "titles" WHERE "userID" = ?`, [userID]))

View file

@ -3,7 +3,7 @@ import { Request, Response } from "express";
export async function viewedVideoSponsorTime(req: Request, res: Response): Promise<Response> {
const UUID = req.query?.UUID;
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
if (!UUID) {
//invalid request
@ -11,7 +11,7 @@ export async function viewedVideoSponsorTime(req: Request, res: Response): Promi
}
//up the view count by one
await db.prepare("run", `UPDATE "sponsorTimes" SET views = views + 1, "updatedAt" = ? WHERE "UUID" = ?`, [isoTimestamp, UUID]);
await db.prepare("run", `UPDATE "sponsorTimes" SET views = views + 1, "updatedAt" = ? WHERE "UUID" = ?`, [isoDate, UUID]);
return res.sendStatus(200);
}

View file

@ -65,10 +65,10 @@ async function updateSegmentVideoDuration(UUID: SegmentUUID) {
apiVideoDetails = await getVideoDetails(videoID, true);
}
const apiVideoDuration = apiVideoDetails?.duration as VideoDuration;
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
if (videoDurationChanged(videoDuration, apiVideoDuration)) {
Logger.info(`Video duration changed for ${videoID} from ${videoDuration} to ${apiVideoDuration}`);
await db.prepare("run", `UPDATE "sponsorTimes" SET "videoDuration" = ?, "updatedAt" ? WHERE "UUID" = ?`, [apiVideoDuration, isoTimestamp, UUID]);
await db.prepare("run", `UPDATE "sponsorTimes" SET "videoDuration" = ?, "updatedAt" ? WHERE "UUID" = ?`, [apiVideoDuration, isoDate, UUID]);
}
}
@ -92,14 +92,14 @@ async function checkVideoDuration(UUID: SegmentUUID) {
ORDER BY "timeSubmitted" DESC LIMIT 1`,
[videoID, service]) as {videoDuration: VideoDuration, UUID: SegmentUUID, timeSubmitted: number};
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
if (latestSubmission && videoDurationChanged(latestSubmission.videoDuration, apiVideoDuration)) {
Logger.info(`Video duration changed for ${videoID} from ${latestSubmission.videoDuration} to ${apiVideoDuration}`);
await db.prepare("run", `UPDATE "sponsorTimes" SET "hidden" = 1, "updatedAt" = ?
WHERE "videoID" = ? AND "service" = ? AND "timeSubmitted" <= ?
AND "hidden" = 0 AND "shadowHidden" = 0 AND
"actionType" != 'full' AND "votes" > -2`,
[isoTimestamp, videoID, service, latestSubmission.timeSubmitted]);
[isoDate, videoID, service, latestSubmission.timeSubmitted]);
deleteLockCategories(videoID, null, null, service).catch((e) => Logger.error(`delete lock categories after vote: ${e}`));
}
}
@ -242,7 +242,7 @@ async function categoryVote(UUID: SegmentUUID, userID: HashedUserID, isVIP: bool
const nextCategoryInfo = await db.prepare("get", `select votes from "categoryVotes" where "UUID" = ? and category = ?`, [UUID, category], { useReplica: true });
const timeSubmitted = Date.now();
const isoTimestamp = new Date(timeSubmitted).toISOString();
const isoDate = new Date(timeSubmitted).toISOString();
const voteAmount = (isVIP || isTempVIP) ? 500 : 1;
const ableToVote = finalResponse.finalStatus === 200; // ban status checks handled by vote() (caller function)
@ -251,16 +251,16 @@ async function categoryVote(UUID: SegmentUUID, userID: HashedUserID, isVIP: bool
// Add the vote
if ((await db.prepare("get", `select count(*) as count from "categoryVotes" where "UUID" = ? and category = ?`, [UUID, category])).count > 0) {
// Update the already existing db entry
await db.prepare("run", `update "categoryVotes" set "votes" = "votes" + ?, "updatedAt" = ? where "UUID" = ? and "category" = ?`, [voteAmount, isoTimestamp, UUID, category]);
await db.prepare("run", `update "categoryVotes" set "votes" = "votes" + ?, "updatedAt" = ? where "UUID" = ? and "category" = ?`, [voteAmount, isoDate, UUID, category]);
} else {
// Add a db entry
await db.prepare("run", `insert into "categoryVotes" ("UUID", "category", "votes", "createdAt", "updatedAt") values (?, ?, ?, ?, ?)`, [UUID, category, voteAmount, isoTimestamp, isoTimestamp]);
await db.prepare("run", `insert into "categoryVotes" ("UUID", "category", "votes", "createdAt", "updatedAt") values (?, ?, ?, ?, ?)`, [UUID, category, voteAmount, isoDate, isoDate]);
}
// Add the info into the private db
if (usersLastVoteInfo?.votes > 0) {
// Reverse the previous vote
await db.prepare("run", `update "categoryVotes" set "votes" = "votes" - ?, "updatedAt" = ? where "UUID" = ? and "category" = ?`, [voteAmount, isoTimestamp, UUID, usersLastVoteInfo.category]);
await db.prepare("run", `update "categoryVotes" set "votes" = "votes" - ?, "updatedAt" = ? where "UUID" = ? and "category" = ?`, [voteAmount, isoDate, UUID, usersLastVoteInfo.category]);
await privateDB.prepare("run", `update "categoryVotes" set "category" = ?, "timeSubmitted" = ?, "hashedIP" = ? where "userID" = ? and "UUID" = ?`, [category, timeSubmitted, hashedIP, userID, UUID]);
} else {
@ -280,7 +280,7 @@ async function categoryVote(UUID: SegmentUUID, userID: HashedUserID, isVIP: bool
// Add submission as vote
if (!currentCategoryInfo && submissionInfo) {
await db.prepare("run", `insert into "categoryVotes" ("UUID", "category", "votes", "createdAt", "updatedAt") values (?, ?, ?)`, [UUID, segmentInfo.category, currentCategoryCount, isoTimestamp, isoTimestamp]);
await db.prepare("run", `insert into "categoryVotes" ("UUID", "category", "votes", "createdAt", "updatedAt") values (?, ?, ?)`, [UUID, segmentInfo.category, currentCategoryCount, isoDate, isoDate]);
await privateDB.prepare("run", `insert into "categoryVotes" ("UUID", "userID", "hashedIP", "category", "timeSubmitted") values (?, ?, ?, ?, ?)`, [UUID, submissionInfo.userID, "unknown", segmentInfo.category, submissionInfo.timeSubmitted]);
}
@ -290,7 +290,7 @@ async function categoryVote(UUID: SegmentUUID, userID: HashedUserID, isVIP: bool
// VIPs change it every time
if (isVIP || isTempVIP || isOwnSubmission || nextCategoryCount - currentCategoryCount >= Math.max(Math.ceil(submissionInfo?.votes / 2), 2)) {
// Replace the category
await db.prepare("run", `update "sponsorTimes" set "category" = ?, "updatedAt" = ? where "UUID" = ?`, [category, isoTimestamp, UUID]);
await db.prepare("run", `update "sponsorTimes" set "category" = ?, "updatedAt" = ? where "UUID" = ?`, [category, isoDate, UUID]);
}
}
QueryCacher.clearSegmentCache(segmentInfo);
@ -513,14 +513,14 @@ export async function vote(ip: IPAddress, UUID: SegmentUUID, paramUserID: UserID
await privateDB.prepare("run", `INSERT INTO "votes" ("UUID", "userID", "hashedIP", "type", "normalUserID", "originalType") VALUES(?, ?, ?, ?, ?, ?)`, [UUID, userID, hashedIP, type, nonAnonUserID, originalType]);
}
const isoTimestamp = new Date().toISOString();
const isoDate = new Date().toISOString();
// update the vote count on this sponsorTime
await db.prepare("run", `UPDATE "sponsorTimes" SET "votes" = "votes" + ?, "updatedAt" = ? WHERE "UUID" = ?`, [incrementAmount - oldIncrementAmount, isoTimestamp, UUID]);
await db.prepare("run", `UPDATE "sponsorTimes" SET "votes" = "votes" + ?, "updatedAt" = ? WHERE "UUID" = ?`, [incrementAmount - oldIncrementAmount, isoDate, UUID]);
// tempVIP can bring back hidden segments
if (isTempVIP && incrementAmount > 0 && voteTypeEnum === voteTypes.normal) {
await db.prepare("run", `UPDATE "sponsorTimes" SET "hidden" = 0, "updatedAt" = ? WHERE "UUID" = ?`, [isoTimestamp, UUID]);
await db.prepare("run", `UPDATE "sponsorTimes" SET "hidden" = 0, "updatedAt" = ? WHERE "UUID" = ?`, [isoDate, UUID]);
}
// additional processing for VIP
// on VIP upvote
@ -528,10 +528,10 @@ export async function vote(ip: IPAddress, UUID: SegmentUUID, paramUserID: UserID
// Update video duration in case that caused it to be hidden
await updateSegmentVideoDuration(UUID);
// unhide & unlock
await db.prepare("run", 'UPDATE "sponsorTimes" SET "locked" = 1, "hidden" = 0, "shadowHidden" = 0, "updatedAt" = ? WHERE "UUID" = ?', [isoTimestamp, UUID]);
await db.prepare("run", 'UPDATE "sponsorTimes" SET "locked" = 1, "hidden" = 0, "shadowHidden" = 0, "updatedAt" = ? WHERE "UUID" = ?', [isoDate, UUID]);
// on VIP downvote/ undovote, also unlock submission
} else if (isVIP && incrementAmount <= 0 && voteTypeEnum === voteTypes.normal) {
await db.prepare("run", 'UPDATE "sponsorTimes" SET "locked" = 0, "updatedAt" = ? WHERE "UUID" = ?', [isoTimestamp, UUID]);
await db.prepare("run", 'UPDATE "sponsorTimes" SET "locked" = 0, "updatedAt" = ? WHERE "UUID" = ?', [isoDate, UUID]);
}
QueryCacher.clearSegmentCache(segmentInfo);