From e5565833f62b97f62ea75eba5b479963ae78b873 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 24 Sep 2018 13:07:33 +0200 Subject: Improve redundancy: add 'min_lifetime' configuration --- server/models/activitypub/actor.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'server/models/activitypub') diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index f8bb59323..12b83916e 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts @@ -37,6 +37,7 @@ import { ServerModel } from '../server/server' import { throwIfNotValid } from '../utils' import { VideoChannelModel } from '../video/video-channel' import { ActorFollowModel } from './actor-follow' +import { VideoModel } from '../video/video' enum ScopeNames { FULL = 'FULL' @@ -266,6 +267,36 @@ export class ActorModel extends Model { return ActorModel.unscoped().findById(id) } + static loadAccountActorByVideoId (videoId: number, transaction: Sequelize.Transaction) { + const query = { + include: [ + { + attributes: [ 'id' ], + model: AccountModel.unscoped(), + required: true, + include: [ + { + attributes: [ 'id' ], + model: VideoChannelModel.unscoped(), + required: true, + include: { + attributes: [ 'id' ], + model: VideoModel.unscoped(), + required: true, + where: { + id: videoId + } + } + } + ] + } + ], + transaction + } + + return ActorModel.unscoped().findOne(query as any) // FIXME: typings + } + static isActorUrlExist (url: string) { const query = { raw: true, -- cgit v1.2.3