X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-channel.ts;h=6241a75a30bfffd499cede0102bd4734781cc838;hb=970ceac0a6bf4990b8924738591df4949491ec9b;hp=b0b261c88a93dc965a3955685244a4256883795f;hpb=b91bc1d1f3591c35ab4426f6ab594b4bd9f1ef62;p=github%2FChocobozzz%2FPeerTube.git 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 }) }