Don't send to #dearrow-locked-titles when downvoting unlocked title

voteType passed to sendWebhooks() function to avoid confusion in the
future should someone forget about the if statement
This commit is contained in:
mini-bomba 2024-08-03 21:10:06 +02:00
parent 19d6d85aa6
commit 61dcfeb69f
No known key found for this signature in database
GPG key ID: 30F8B138B4794886

View file

@ -113,7 +113,7 @@ export async function postBranding(req: Request, res: Response) {
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]);
}
sendWebhooks(videoID, UUID).catch((e) => Logger.error(e));
sendWebhooks(videoID, UUID, voteType).catch((e) => Logger.error(e));
}
})(), (async () => {
if (thumbnail) {
@ -290,7 +290,9 @@ export async function verifyOldSubmissions(hashedUserID: HashedUserID, verificat
}
}
async function sendWebhooks(videoID: VideoID, UUID: BrandingUUID) {
async function sendWebhooks(videoID: VideoID, UUID: BrandingUUID, voteType: BrandingVoteType) {
if (voteType === BrandingVoteType.Downvote) return; // Don't send messages to dearrow-locked-titles on downvotes
const lockedSubmission = await db.prepare("get", `SELECT "titleVotes"."votes", "titles"."title", "titles"."userID" FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID" WHERE "titles"."videoID" = ? AND "titles"."UUID" != ? AND "titleVotes"."locked" = 1`, [videoID, UUID]);
if (lockedSubmission) {