From 89613cb444b4e1601d202153d0ec8635392ec872 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 2 Feb 2021 08:48:48 +0100 Subject: Purge entire video from redundancy --- server/models/redundancy/video-redundancy.ts | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'server/models/redundancy') diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 98c6ff134..74895fe30 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts @@ -185,6 +185,57 @@ export class VideoRedundancyModel extends Model { return VideoRedundancyModel.scope(ScopeNames.WITH_VIDEO).findOne(query) } + static async listLocalByVideoId (videoId: number): Promise { + const actor = await getServerActor() + + const queryStreamingPlaylist = { + where: { + actorId: actor.id + }, + include: [ + { + model: VideoStreamingPlaylistModel.unscoped(), + required: true, + include: [ + { + model: VideoModel.unscoped(), + required: true, + where: { + id: videoId + } + } + ] + } + ] + } + + const queryFiles = { + where: { + actorId: actor.id + }, + include: [ + { + model: VideoFileModel, + required: true, + include: [ + { + model: VideoModel, + required: true, + where: { + id: videoId + } + } + ] + } + ] + } + + return Promise.all([ + VideoRedundancyModel.findAll(queryStreamingPlaylist), + VideoRedundancyModel.findAll(queryFiles) + ]).then(([ r1, r2 ]) => r1.concat(r2)) + } + static async loadLocalByStreamingPlaylistId (videoStreamingPlaylistId: number): Promise { const actor = await getServerActor() -- cgit v1.2.3