aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-02-04 16:14:33 +0100
committerChocobozzz <me@florianbigard.com>2020-02-04 16:18:01 +0100
commit2c8776fc316da9719e5ebc55dfabdcac9e197ac4 (patch)
treeb8e8365092437ee69f2ef88d0e9d858fae15ec45 /server/models
parent943e5193905908dd1f2800d8810c635d86e3b28f (diff)
downloadPeerTube-2c8776fc316da9719e5ebc55dfabdcac9e197ac4.tar.gz
PeerTube-2c8776fc316da9719e5ebc55dfabdcac9e197ac4.tar.zst
PeerTube-2c8776fc316da9719e5ebc55dfabdcac9e197ac4.zip
Optimize view endpoint
Diffstat (limited to 'server/models')
-rw-r--r--server/models/activitypub/actor.ts30
1 files changed, 30 insertions, 0 deletions
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<ActorModel> {
462 }, { where, transaction }) 462 }, { where, transaction })
463 } 463 }
464 464
465 static loadAccountActorByVideoId (videoId: number): Bluebird<MActor> {
466 const query = {
467 include: [
468 {
469 attributes: [ 'id' ],
470 model: AccountModel.unscoped(),
471 required: true,
472 include: [
473 {
474 attributes: [ 'id', 'accountId' ],
475 model: VideoChannelModel.unscoped(),
476 required: true,
477 include: [
478 {
479 attributes: [ 'id', 'channelId' ],
480 model: VideoModel.unscoped(),
481 where: {
482 id: videoId
483 }
484 }
485 ]
486 }
487 ]
488 }
489 ]
490 }
491
492 return ActorModel.unscoped().findOne(query)
493 }
494
465 getSharedInbox (this: MActorWithInboxes) { 495 getSharedInbox (this: MActorWithInboxes) {
466 return this.sharedInboxUrl || this.inboxUrl 496 return this.sharedInboxUrl || this.inboxUrl
467 } 497 }