mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 05:57:04 +03:00
Use includes and check in sql usage
This commit is contained in:
committed by
GitHub
parent
74c0ba37e2
commit
d8e0eac61b
@@ -23,7 +23,7 @@ export async function shadowBanUser(req: Request, res: Response): Promise<Respon
|
|||||||
|
|
||||||
const categories: Category[] = parseCategories(req, config.categoryList as Category[]);
|
const categories: Category[] = parseCategories(req, config.categoryList as Category[]);
|
||||||
|
|
||||||
if (adminUserIDInput == undefined || (userID == undefined && hashedIP == undefined || type !== "1" && type !== "2")) {
|
if (adminUserIDInput == undefined || (userID == undefined && hashedIP == undefined || !["1", "2"].includes(type))) {
|
||||||
//invalid request
|
//invalid request
|
||||||
return res.sendStatus(400);
|
return res.sendStatus(400);
|
||||||
}
|
}
|
||||||
@@ -119,6 +119,8 @@ export async function shadowBanUser(req: Request, res: Response): Promise<Respon
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function unHideSubmissions(categories: string[], userID: UserID, type = "1") {
|
async function unHideSubmissions(categories: string[], userID: UserID, type = "1") {
|
||||||
|
if (!["1", "2"].includes(type)) return;
|
||||||
|
|
||||||
await db.prepare("run", `UPDATE "sponsorTimes" SET "shadowHidden" = ${type} WHERE "userID" = ? AND "category" in (${categories.map((c) => `'${c}'`).join(",")})
|
await db.prepare("run", `UPDATE "sponsorTimes" SET "shadowHidden" = ${type} WHERE "userID" = ? AND "category" in (${categories.map((c) => `'${c}'`).join(",")})
|
||||||
AND NOT EXISTS ( SELECT "videoID", "category" FROM "lockCategories" WHERE
|
AND NOT EXISTS ( SELECT "videoID", "category" FROM "lockCategories" WHERE
|
||||||
"sponsorTimes"."videoID" = "lockCategories"."videoID" AND "sponsorTimes"."service" = "lockCategories"."service" AND "sponsorTimes"."category" = "lockCategories"."category")`, [userID]);
|
"sponsorTimes"."videoID" = "lockCategories"."videoID" AND "sponsorTimes"."service" = "lockCategories"."service" AND "sponsorTimes"."category" = "lockCategories"."category")`, [userID]);
|
||||||
|
|||||||
Reference in New Issue
Block a user