From 511765c9f86fb07d5d856decd9dbf0ec2092f4fe Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Aug 2019 15:35:29 +0200 Subject: Remove comment federation by video owner --- server/models/video/video-comment.ts | 43 +++++------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) (limited to 'server/models') diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index 6eda32f05..58b75510d 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts @@ -105,6 +105,10 @@ enum ScopeNames { model: VideoChannelModel.unscoped(), required: true, include: [ + { + model: ActorModel, + required: true + }, { model: AccountModel, required: true, @@ -208,41 +212,6 @@ export class VideoCommentModel extends Model { }) Account: AccountModel - @BeforeDestroy - static async sendDeleteIfOwned (instance: VideoCommentModel, options) { - if (!instance.Account || !instance.Account.Actor) { - instance.Account = await instance.$get('Account', { - include: [ ActorModel ], - transaction: options.transaction - }) as AccountModel - } - - if (!instance.Video) { - instance.Video = await instance.$get('Video', { - include: [ - { - model: VideoChannelModel, - include: [ - { - model: AccountModel, - include: [ - { - model: ActorModel - } - ] - } - ] - } - ], - transaction: options.transaction - }) as VideoModel - } - - if (instance.isOwned()) { - await sendDeleteVideoComment(instance, options.transaction) - } - } - static loadById (id: number, t?: Transaction) { const query: FindOptions = { where: { @@ -269,7 +238,7 @@ export class VideoCommentModel extends Model { .findOne(query) } - static loadByUrlAndPopulateAccount (url: string, t?: Transaction) { + static loadByUrlAndPopulateAccountAndVideo (url: string, t?: Transaction) { const query: FindOptions = { where: { url @@ -278,7 +247,7 @@ export class VideoCommentModel extends Model { if (t !== undefined) query.transaction = t - return VideoCommentModel.scope([ ScopeNames.WITH_ACCOUNT ]).findOne(query) + return VideoCommentModel.scope([ ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_VIDEO ]).findOne(query) } static loadByUrlAndPopulateReplyAndVideoUrlAndAccount (url: string, t?: Transaction) { -- cgit v1.2.3