From 4beda9e12adc7b1f3b178cecd6863ebf3cf431f1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 19 Oct 2021 09:44:43 +0200 Subject: Add ability to view my followers --- server/models/actor/actor-follow.ts | 22 +++++++++------------- server/models/video/video-channel.ts | 24 ++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 15 deletions(-) (limited to 'server/models') diff --git a/server/models/actor/actor-follow.ts b/server/models/actor/actor-follow.ts index fc1cc7499..d6a2387a5 100644 --- a/server/models/actor/actor-follow.ts +++ b/server/models/actor/actor-follow.ts @@ -143,7 +143,7 @@ export class ActorFollowModel extends Model { + static listSubscriptionsOf (actorId: number, targets: { name: string, host?: string }[]): Promise { const whereTab = targets .map(t => { if (t.host) { @@ -348,7 +348,7 @@ export class ActorFollowModel extends ModelActor"."serverId" = "Account->Actor->Server"."id"` }) } - static listByAccount (options: { + static listByAccountForAPI (options: { accountId: number start: number count: number @@ -582,6 +582,26 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` }) } + + static listAllByAccount (accountId: number) { + const query = { + limit: VIDEO_CHANNELS.MAX_PER_USER, + include: [ + { + attributes: [], + model: AccountModel, + where: { + id: accountId + }, + required: true + } + ] + } + + return VideoChannelModel.findAll(query) + } + + static loadAndPopulateAccount (id: number, transaction?: Transaction): Promise { return VideoChannelModel.unscoped() .scope([ ScopeNames.WITH_ACTOR_BANNER, ScopeNames.WITH_ACCOUNT ]) -- cgit v1.2.3