From bfbd912886eba17b4aa9a40dcef2fddc685d85bf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 31 Jul 2019 15:57:32 +0200 Subject: Fix broken playlist api --- server/models/video/video-channel.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'server/models/video/video-channel.ts') diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index b0b261c88..6241a75a3 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -24,7 +24,7 @@ import { isVideoChannelSupportValid } from '../../helpers/custom-validators/video-channels' import { sendDeleteActor } from '../../lib/activitypub/send' -import { AccountModel, ScopeNames as AccountModelScopeNames } from '../account/account' +import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' import { VideoModel } from './video' @@ -58,6 +58,11 @@ type AvailableForListOptions = { actorId: number } +export type SummaryOptions = { + withAccount?: boolean // Default: false + withAccountBlockerIds?: number[] +} + @DefaultScope(() => ({ include: [ { @@ -67,7 +72,7 @@ type AvailableForListOptions = { ] })) @Scopes(() => ({ - [ScopeNames.SUMMARY]: (withAccount = false) => { + [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => { const base: FindOptions = { attributes: [ 'name', 'description', 'id', 'actorId' ], include: [ @@ -90,9 +95,11 @@ type AvailableForListOptions = { ] } - if (withAccount === true) { + if (options.withAccount === true) { base.include.push({ - model: AccountModel.scope(AccountModelScopeNames.SUMMARY), + model: AccountModel.scope({ + method: [ AccountModelScopeNames.SUMMARY, { withAccountBlockerIds: options.withAccountBlockerIds } as AccountSummaryOptions ] + }), required: true }) } -- cgit v1.2.3