mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
Use includes and check in sql usage
This commit is contained in:
parent
74c0ba37e2
commit
d8e0eac61b
1 changed files with 3 additions and 1 deletions
|
@ -23,7 +23,7 @@ export async function shadowBanUser(req: Request, res: Response): Promise<Respon
|
|||
|
||||
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
|
||||
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") {
|
||||
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(",")})
|
||||
AND NOT EXISTS ( SELECT "videoID", "category" FROM "lockCategories" WHERE
|
||||
"sponsorTimes"."videoID" = "lockCategories"."videoID" AND "sponsorTimes"."service" = "lockCategories"."service" AND "sponsorTimes"."category" = "lockCategories"."category")`, [userID]);
|
||||
|
|
Loading…
Reference in a new issue