From 265ba139ebf56bbdc1c65f6ea4f367774c691fc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 3 Jan 2018 16:38:50 +0100 Subject: Send account activitypub update events --- server/models/video/video-share.ts | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'server/models/video') diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts index c252fd646..56576f98c 100644 --- a/server/models/video/video-share.ts +++ b/server/models/video/video-share.ts @@ -1,7 +1,9 @@ import * as Sequelize from 'sequelize' import { BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' +import { AccountModel } from '../account/account' import { ActorModel } from '../activitypub/actor' import { VideoModel } from './video' +import { VideoChannelModel } from './video-channel' enum ScopeNames { FULL = 'FULL', @@ -99,4 +101,42 @@ export class VideoShareModel extends Model { return VideoShareModel.scope(ScopeNames.FULL).findAll(query) .then(res => res.map(r => r.Actor)) } + + static loadActorsByVideoOwner (actorOwnerId: number, t: Sequelize.Transaction) { + const query = { + attributes: [], + include: [ + { + model: ActorModel, + required: true + }, + { + attributes: [], + model: VideoModel, + required: true, + include: [ + { + attributes: [], + model: VideoChannelModel.unscoped(), + required: true, + include: [ + { + attributes: [], + model: AccountModel.unscoped(), + required: true, + where: { + actorId: actorOwnerId + } + } + ] + } + ] + } + ], + transaction: t + } + + return VideoShareModel.scope(ScopeNames.FULL).findAll(query) + .then(res => res.map(r => r.Actor)) + } } -- cgit v1.2.3