From 99492dbc0d87ef54d0dab7d8d44f8d0de5722bdd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 21 Aug 2018 10:34:18 +0200 Subject: Add get subscription endpoint --- server/models/activitypub/actor-follow.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'server/models/activitypub') diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index 90a8ac43c..20d3aa5fc 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts @@ -28,6 +28,7 @@ import { ServerModel } from '../server/server' import { getSort } from '../utils' import { ActorModel } from './actor' import { VideoChannelModel } from '../video/video-channel' +import { IIncludeOptions } from '../../../node_modules/sequelize-typescript/lib/interfaces/IIncludeOptions' @Table({ tableName: 'actorFollow', @@ -166,28 +167,30 @@ export class ActorFollowModel extends Model { } static loadByActorAndTargetNameAndHost (actorId: number, targetName: string, targetHost: string, t?: Sequelize.Transaction) { - const actorFollowingPartInclude = { + const actorFollowingPartInclude: IIncludeOptions = { model: ActorModel, required: true, as: 'ActorFollowing', where: { preferredUsername: targetName - } + }, + include: [ + { + model: VideoChannelModel, + required: false + } + ] } if (targetHost === null) { actorFollowingPartInclude.where['serverId'] = null } else { - Object.assign(actorFollowingPartInclude, { - include: [ - { - model: ServerModel, - required: true, - where: { - host: targetHost - } - } - ] + actorFollowingPartInclude.include.push({ + model: ServerModel, + required: true, + where: { + host: targetHost + } }) } -- cgit v1.2.3