From 2c8776fc316da9719e5ebc55dfabdcac9e197ac4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Feb 2020 16:14:33 +0100 Subject: Optimize view endpoint --- server/models/activitypub/actor.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'server/models') diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index 9e8303a7b..e547d2c0c 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts @@ -462,6 +462,36 @@ export class ActorModel extends Model { }, { where, transaction }) } + static loadAccountActorByVideoId (videoId: number): Bluebird { + const query = { + include: [ + { + attributes: [ 'id' ], + model: AccountModel.unscoped(), + required: true, + include: [ + { + attributes: [ 'id', 'accountId' ], + model: VideoChannelModel.unscoped(), + required: true, + include: [ + { + attributes: [ 'id', 'channelId' ], + model: VideoModel.unscoped(), + where: { + id: videoId + } + } + ] + } + ] + } + ] + } + + return ActorModel.unscoped().findOne(query) + } + getSharedInbox (this: MActorWithInboxes) { return this.sharedInboxUrl || this.inboxUrl } -- cgit v1.2.3