From 161b061d4e51eb1e2b2b7e9482d5299489ef7c45 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 Sep 2018 10:07:05 +0200 Subject: Remove duplicated videos on unfollow/delete redundancy --- server/models/redundancy/video-redundancy.ts | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'server/models/redundancy') diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 3c87ec2c1..e67164802 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts @@ -286,6 +286,47 @@ export class VideoRedundancyModel extends Model { return VideoRedundancyModel.scope([ ScopeNames.WITH_VIDEO ]).findAll(query) } + static async listLocalOfServer (serverId: number) { + const actor = await getServerActor() + + const query = { + where: { + actorId: actor.id + }, + include: [ + { + model: VideoFileModel, + required: true, + include: [ + { + model: VideoModel, + required: true, + include: [ + { + attributes: [], + model: VideoChannelModel.unscoped(), + required: true, + include: [ + { + attributes: [], + model: ActorModel.unscoped(), + required: true, + where: { + serverId + } + } + ] + } + ] + } + ] + } + ] + } + + return VideoRedundancyModel.findAll(query) + } + static async getStats (strategy: VideoRedundancyStrategy) { const actor = await getServerActor() -- cgit v1.2.3