diff --git a/src/routes/postBranding.ts b/src/routes/postBranding.ts index 33128e7..7fa2e6b 100644 --- a/src/routes/postBranding.ts +++ b/src/routes/postBranding.ts @@ -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) { @@ -336,4 +338,4 @@ async function checkForWrongVideoDuration(videoID: VideoID, duration: number): P const apiDuration = apiVideoDetails?.duration; return apiDuration && apiDuration > 2 && duration && duration > 2 && Math.abs(apiDuration - duration) > 3; -} \ No newline at end of file +}