mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 22:17:14 +03:00
Add warning when locked title probably outdated
This commit is contained in:
@@ -45,6 +45,7 @@ addDefaults(config, {
|
|||||||
discordFailedReportChannelWebhookURL: null,
|
discordFailedReportChannelWebhookURL: null,
|
||||||
discordReportChannelWebhookURL: null,
|
discordReportChannelWebhookURL: null,
|
||||||
discordMaliciousReportWebhookURL: null,
|
discordMaliciousReportWebhookURL: null,
|
||||||
|
discordDeArrowLockedWebhookURL: null,
|
||||||
minReputationToSubmitChapter: 0,
|
minReputationToSubmitChapter: 0,
|
||||||
minReputationToSubmitFiller: 0,
|
minReputationToSubmitFiller: 0,
|
||||||
getTopUsersCacheTimeMinutes: 240,
|
getTopUsersCacheTimeMinutes: 240,
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import { QueryCacher } from "../utils/queryCacher";
|
|||||||
import { acquireLock } from "../utils/redisLock";
|
import { acquireLock } from "../utils/redisLock";
|
||||||
import { hasFeature } from "../utils/features";
|
import { hasFeature } from "../utils/features";
|
||||||
import { checkBanStatus } from "../utils/checkBan";
|
import { checkBanStatus } from "../utils/checkBan";
|
||||||
|
import axios from "axios";
|
||||||
|
import { getMaxResThumbnail } from "../utils/youtubeApi";
|
||||||
|
import { getVideoDetails } from "../utils/getVideoDetails";
|
||||||
|
|
||||||
enum BrandingType {
|
enum BrandingType {
|
||||||
Title,
|
Title,
|
||||||
@@ -88,6 +91,8 @@ export async function postBranding(req: Request, res: Response) {
|
|||||||
// unlock all other titles
|
// unlock all other titles
|
||||||
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).catch((e) => Logger.error(e));
|
||||||
}
|
}
|
||||||
})(), (async () => {
|
})(), (async () => {
|
||||||
if (thumbnail) {
|
if (thumbnail) {
|
||||||
@@ -201,3 +206,44 @@ export async function verifyOldSubmissions(hashedUserID: HashedUserID, verificat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function sendWebhooks(videoID: VideoID, UUID: BrandingUUID) {
|
||||||
|
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) {
|
||||||
|
const currentSubmission = await db.prepare("get", `SELECT "titleVotes"."votes", "titles"."title" FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID" WHERE "titles"."UUID" = ?`, [UUID]);
|
||||||
|
|
||||||
|
// Time to warn that there may be an issue
|
||||||
|
if (currentSubmission.votes - lockedSubmission.votes > 2) {
|
||||||
|
const usernameRow = await db.prepare("get", `SELECT "userName" FROM "userNames" WHERE "userID" = ?`, [lockedSubmission.userID]);
|
||||||
|
|
||||||
|
const data = await getVideoDetails(videoID);
|
||||||
|
axios.post(config.discordDeArrowLockedWebhookURL, {
|
||||||
|
"embeds": [{
|
||||||
|
"title": data?.title,
|
||||||
|
"url": `https://www.youtube.com/watch?v=${videoID}`,
|
||||||
|
"description": `**${lockedSubmission.votes}** Votes vs **${currentSubmission.votes}**\
|
||||||
|
\n\n**Locked title:** ${lockedSubmission.title}\
|
||||||
|
\n**New title:** ${currentSubmission.title}\
|
||||||
|
\n\n**Submitted by:** ${usernameRow?.userName ?? ""}\n${lockedSubmission.userID}`,
|
||||||
|
"color": 10813440,
|
||||||
|
"thumbnail": {
|
||||||
|
"url": getMaxResThumbnail(videoID),
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.status >= 400) {
|
||||||
|
Logger.error("Error sending reported submission Discord hook");
|
||||||
|
Logger.error(JSON.stringify((res.data)));
|
||||||
|
Logger.error("\n");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
Logger.error("Failed to send reported submission Discord hook.");
|
||||||
|
Logger.error(JSON.stringify(err));
|
||||||
|
Logger.error("\n");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,6 +48,7 @@ export interface SBSConfig {
|
|||||||
discordFirstTimeSubmissionsWebhookURL?: string;
|
discordFirstTimeSubmissionsWebhookURL?: string;
|
||||||
discordCompletelyIncorrectReportWebhookURL?: string;
|
discordCompletelyIncorrectReportWebhookURL?: string;
|
||||||
discordMaliciousReportWebhookURL?: string;
|
discordMaliciousReportWebhookURL?: string;
|
||||||
|
discordDeArrowLockedWebhookURL?: string,
|
||||||
neuralBlockURL?: string;
|
neuralBlockURL?: string;
|
||||||
discordNeuralBlockRejectWebhookURL?: string;
|
discordNeuralBlockRejectWebhookURL?: string;
|
||||||
minReputationToSubmitChapter: number;
|
minReputationToSubmitChapter: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user