From 42ec411bf879ef9505b93f74610d787320643193 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 9 Mar 2021 16:10:52 +0100 Subject: Fix abuse tests --- server/models/video/video.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'server/models/video') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index b3543ddf2..9d89efa5b 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -783,21 +783,20 @@ export class VideoModel extends Model { @BeforeDestroy static async sendDelete (instance: MVideoAccountLight, options) { - if (instance.isOwned()) { - if (!instance.VideoChannel) { - instance.VideoChannel = await instance.$get('VideoChannel', { - include: [ - ActorModel, - AccountModel - ], - transaction: options.transaction - }) as MChannelAccountDefault - } + if (!instance.isOwned()) return undefined - return sendDeleteVideo(instance, options.transaction) + // Lazy load channels + if (!instance.VideoChannel) { + instance.VideoChannel = await instance.$get('VideoChannel', { + include: [ + ActorModel, + AccountModel + ], + transaction: options.transaction + }) as MChannelAccountDefault } - return undefined + return sendDeleteVideo(instance, options.transaction) } @BeforeDestroy @@ -862,6 +861,7 @@ export class VideoModel extends Model { logger.info('Saving video abuses details of video %s.', instance.url) + if (!instance.Trackers) instance.Trackers = await instance.$get('Trackers', { transaction: options.transaction }) const details = instance.toFormattedDetailsJSON() for (const abuse of instance.VideoAbuses) { -- cgit v1.2.3