mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-10 13:37:01 +03:00
add service to table only have videoID
This commit is contained in:
@@ -2,18 +2,20 @@ import { db } from "../databases/databases";
|
||||
import { Logger } from "../utils/logger";
|
||||
import { Request, Response } from "express";
|
||||
import { Category, VideoID } from "../types/segments.model";
|
||||
import { getService } from "../utils/getService";
|
||||
|
||||
export async function getLockCategories(req: Request, res: Response): Promise<Response> {
|
||||
const videoID = req.query.videoID as VideoID;
|
||||
const service = getService(req.query.service as string);
|
||||
|
||||
if (videoID == undefined) {
|
||||
//invalid request
|
||||
return res.sendStatus(400);
|
||||
}
|
||||
|
||||
console.log(service);
|
||||
try {
|
||||
// Get existing lock categories markers
|
||||
const row = await db.prepare("all", 'SELECT "category", "reason" from "lockCategories" where "videoID" = ?', [videoID]) as {category: Category, reason: string}[];
|
||||
const row = await db.prepare("all", 'SELECT "category", "reason" from "lockCategories" where "videoID" = ? AND "service" = ?', [videoID, service]) as {category: Category, reason: string}[];
|
||||
// map categories to array in JS becaues of SQL incompatibilities
|
||||
const categories = row.map(item => item.category);
|
||||
if (categories.length === 0 || !categories[0]) return res.sendStatus(404);
|
||||
|
||||
Reference in New Issue
Block a user