Clear cache after purging segments

This commit is contained in:
Ajay Ramachandran 2021-09-29 16:31:44 -04:00
parent eaaf106d7c
commit 99d72b92e4

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);