mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 20:17:02 +03:00
don't send dearrow webhooks for banned users
This commit is contained in:
@@ -74,7 +74,7 @@ export async function postBranding(req: Request, res: Response) {
|
|||||||
endpoint: "dearrow-postBranding",
|
endpoint: "dearrow-postBranding",
|
||||||
});
|
});
|
||||||
if (matchedRule !== null) {
|
if (matchedRule !== null) {
|
||||||
sendNewUserWebhook(config.discordRejectedNewUserWebhookURL, hashedUserID, videoID, userAgent, req, videoDuration, title, matchedRule);
|
sendNewUserWebhook(config.discordRejectedNewUserWebhookURL, hashedUserID, videoID, userAgent, req, videoDuration, title, `Caught by rule: ${matchedRule}`);
|
||||||
Logger.warn(`Dearrow submission rejected by request validator: ${hashedUserID} ${videoID} ${videoDuration} ${userAgent} ${req.headers["user-agent"]} ${title.title} ${thumbnail.timestamp}`);
|
Logger.warn(`Dearrow submission rejected by request validator: ${hashedUserID} ${videoID} ${videoDuration} ${userAgent} ${req.headers["user-agent"]} ${title.title} ${thumbnail.timestamp}`);
|
||||||
res.status(200).send("OK");
|
res.status(200).send("OK");
|
||||||
return;
|
return;
|
||||||
@@ -121,7 +121,7 @@ export async function postBranding(req: Request, res: Response) {
|
|||||||
const existingIsLocked = !!existingUUID && (await db.prepare("get", `SELECT "locked" from "titleVotes" where "UUID" = ?`, [existingUUID]))?.locked;
|
const existingIsLocked = !!existingUUID && (await db.prepare("get", `SELECT "locked" from "titleVotes" where "UUID" = ?`, [existingUUID]))?.locked;
|
||||||
if (existingUUID != undefined && isBanned) return; // ignore votes on existing details from banned users
|
if (existingUUID != undefined && isBanned) return; // ignore votes on existing details from banned users
|
||||||
if (downvote && existingIsLocked && !isVip) {
|
if (downvote && existingIsLocked && !isVip) {
|
||||||
sendWebhooks(videoID, existingUUID, voteType, wasWarned, shouldLock).catch((e) => Logger.error(e));
|
if (!isBanned) sendWebhooks(videoID, existingUUID, voteType, wasWarned, shouldLock).catch((e) => Logger.error(e));
|
||||||
errorCode = 403;
|
errorCode = 403;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,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]);
|
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, voteType, wasWarned, shouldLock).catch((e) => Logger.error(e));
|
if (!isBanned) sendWebhooks(videoID, UUID, voteType, wasWarned, shouldLock).catch((e) => Logger.error(e));
|
||||||
}
|
}
|
||||||
})(), (async () => {
|
})(), (async () => {
|
||||||
if (thumbnail) {
|
if (thumbnail) {
|
||||||
@@ -211,7 +211,7 @@ export async function postBranding(req: Request, res: Response) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendNewUserWebhook(webhookUrl: string, hashedUserID: HashedUserID, videoID: VideoID, userAgent: any, req: Request, videoDuration: number, title: TitleSubmission, ruleName: string | undefined) {
|
function sendNewUserWebhook(webhookUrl: string, hashedUserID: HashedUserID, videoID: VideoID, userAgent: any, req: Request, videoDuration: number, title: TitleSubmission, footerText: string | undefined) {
|
||||||
if (!webhookUrl) return;
|
if (!webhookUrl) return;
|
||||||
|
|
||||||
axios.post(webhookUrl, {
|
axios.post(webhookUrl, {
|
||||||
@@ -227,8 +227,8 @@ function sendNewUserWebhook(webhookUrl: string, hashedUserID: HashedUserID, vide
|
|||||||
"thumbnail": {
|
"thumbnail": {
|
||||||
"url": getMaxResThumbnail(videoID),
|
"url": getMaxResThumbnail(videoID),
|
||||||
},
|
},
|
||||||
"footer": {
|
"footer": footerText === undefined ? null : {
|
||||||
"text": ruleName === undefined ? `Caught by permission check` : `Caught by rule '${ruleName}'`,
|
"text": footerText,
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user