mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-25 17:08:35 +03:00
Reformat SQL code in postBranding.ts webhook code
This commit is contained in:
@@ -292,11 +292,30 @@ export async function verifyOldSubmissions(hashedUserID: HashedUserID, verificat
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function sendWebhooks(videoID: VideoID, UUID: BrandingUUID, voteType: BrandingVoteType) {
|
async function sendWebhooks(videoID: VideoID, UUID: BrandingUUID, voteType: BrandingVoteType) {
|
||||||
const currentSubmission = await db.prepare("get", `SELECT "titleVotes"."votes", "titles"."title", "titleVotes"."locked", "titles"."userID", "titleVotes"."votes"-"titleVotes"."downvotes"+"titleVotes"."verification" AS "score" FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID" WHERE "titles"."UUID" = ?`, [UUID]);
|
const currentSubmission = await db.prepare(
|
||||||
|
"get",
|
||||||
|
`SELECT
|
||||||
|
"titles"."title",
|
||||||
|
"titleVotes"."locked",
|
||||||
|
"titles"."userID",
|
||||||
|
"titleVotes"."votes"-"titleVotes"."downvotes"+"titleVotes"."verification" AS "score"
|
||||||
|
FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID"
|
||||||
|
WHERE "titles"."UUID" = ?`,
|
||||||
|
[UUID]);
|
||||||
|
|
||||||
// Unlocked title getting more upvotes than the locked one
|
// Unlocked title getting more upvotes than the locked one
|
||||||
if (voteType === BrandingVoteType.Upvote) {
|
if (voteType === BrandingVoteType.Upvote) {
|
||||||
const lockedSubmission = await db.prepare("get", `SELECT "titleVotes"."votes", "titles"."title", "titles"."userID", "titleVotes"."votes"-"titleVotes"."downvotes"+"titleVotes"."verification" AS "score" FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID" WHERE "titles"."videoID" = ? AND "titles"."UUID" != ? AND "titleVotes"."locked" = 1`, [videoID, UUID]);
|
const lockedSubmission = await db.prepare(
|
||||||
|
"get",
|
||||||
|
`SELECT
|
||||||
|
"titles"."title",
|
||||||
|
"titles"."userID",
|
||||||
|
"titleVotes"."votes"-"titleVotes"."downvotes"+"titleVotes"."verification" AS "score"
|
||||||
|
FROM "titles" JOIN "titleVotes" ON "titles"."UUID" = "titleVotes"."UUID"
|
||||||
|
WHERE "titles"."videoID" = ?
|
||||||
|
AND "titles"."UUID" != ?
|
||||||
|
AND "titleVotes"."locked" = 1`,
|
||||||
|
[videoID, UUID]);
|
||||||
|
|
||||||
// Time to warn that there may be an issue
|
// Time to warn that there may be an issue
|
||||||
if (lockedSubmission && currentSubmission.score - lockedSubmission.score > 2) {
|
if (lockedSubmission && currentSubmission.score - lockedSubmission.score > 2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user