mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-13 15:06:59 +03:00
Fix crash when categories array is broken
This commit is contained in:
@@ -57,9 +57,13 @@ export async function deleteLockCategoriesEndpoint(req: DeleteLockCategoriesRequ
|
|||||||
return res.status(200).json({ message: `Removed lock categories entries for video ${videoID}` });
|
return res.status(200).json({ message: `Removed lock categories entries for video ${videoID}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteLockCategories(videoID: VideoID, categories = config.categoryList, actionTypes = [ActionType.Skip, ActionType.Mute], service: Service): Promise<void> {
|
export async function deleteLockCategories(videoID: VideoID, categories: Category[], actionTypes: ActionType[], service: Service): Promise<void> {
|
||||||
|
categories ??= config.categoryList as Category[];
|
||||||
|
actionTypes ??= [ActionType.Skip, ActionType.Mute];
|
||||||
|
|
||||||
const arrJoin = (arr: string[]): string => `'${arr.join(`','`)}'`;
|
const arrJoin = (arr: string[]): string => `'${arr.join(`','`)}'`;
|
||||||
const categoryString = arrJoin(categories.filter((v) => !/[^a-z|_|-]/.test(v)));
|
const categoryString = arrJoin(categories.filter((v) => !/[^a-z|_|-]/.test(v)));
|
||||||
const actionTypeString = arrJoin(actionTypes.filter((v) => !/[^a-z|_|-]/.test(v)));
|
const actionTypeString = arrJoin(actionTypes.filter((v) => !/[^a-z|_|-]/.test(v)));
|
||||||
|
|
||||||
await db.prepare("run", `DELETE FROM "lockCategories" WHERE "videoID" = ? AND "service" = ? AND "category" IN (${categoryString}) AND "actionType" IN (${actionTypeString})`, [videoID, service]);
|
await db.prepare("run", `DELETE FROM "lockCategories" WHERE "videoID" = ? AND "service" = ? AND "category" IN (${categoryString}) AND "actionType" IN (${actionTypeString})`, [videoID, service]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user