This commit is contained in:
Ajay Ramachandran 2021-10-03 08:56:42 +02:00
commit 543fb535df

View file

@ -3,11 +3,13 @@ import { getHash } from "../utils/getHash";
import { isUserVIP } from "../utils/isUserVIP";
import { Request, Response } from "express";
import { HashedUserID, UserID } from "../types/user.model";
import { VideoID } from "../types/segments.model";
import { Service, VideoID, VideoIDHash } from "../types/segments.model";
import { db } from "../databases/databases";
import { QueryCacher } from "../utils/queryCacher";
export async function postPurgeAllSegments(req: Request, res: Response): Promise<Response> {
const userID = req.body.userID as UserID;
const service = req.body.service as Service ?? Service.YouTube;
const videoID = req.body.videoID as VideoID;
if (userID == undefined) {
@ -28,6 +30,13 @@ export async function postPurgeAllSegments(req: Request, res: Response): Promise
await db.prepare("run", `UPDATE "sponsorTimes" SET "hidden" = 1 WHERE "videoID" = ?`, [videoID]);
const hashedVideoID: VideoIDHash = getHash(videoID, 1);
QueryCacher.clearVideoCache({
videoID,
hashedVideoID,
service
});
} catch (err) {
Logger.error(err as string);
return res.sendStatus(500);