aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-channel.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r--server/models/video/video-channel.ts15
1 files changed, 11 insertions, 4 deletions
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 {
24 isVideoChannelSupportValid 24 isVideoChannelSupportValid
25} from '../../helpers/custom-validators/video-channels' 25} from '../../helpers/custom-validators/video-channels'
26import { sendDeleteActor } from '../../lib/activitypub/send' 26import { sendDeleteActor } from '../../lib/activitypub/send'
27import { AccountModel, ScopeNames as AccountModelScopeNames } from '../account/account' 27import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account'
28import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' 28import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor'
29import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' 29import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils'
30import { VideoModel } from './video' 30import { VideoModel } from './video'
@@ -58,6 +58,11 @@ type AvailableForListOptions = {
58 actorId: number 58 actorId: number
59} 59}
60 60
61export type SummaryOptions = {
62 withAccount?: boolean // Default: false
63 withAccountBlockerIds?: number[]
64}
65
61@DefaultScope(() => ({ 66@DefaultScope(() => ({
62 include: [ 67 include: [
63 { 68 {
@@ -67,7 +72,7 @@ type AvailableForListOptions = {
67 ] 72 ]
68})) 73}))
69@Scopes(() => ({ 74@Scopes(() => ({
70 [ScopeNames.SUMMARY]: (withAccount = false) => { 75 [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => {
71 const base: FindOptions = { 76 const base: FindOptions = {
72 attributes: [ 'name', 'description', 'id', 'actorId' ], 77 attributes: [ 'name', 'description', 'id', 'actorId' ],
73 include: [ 78 include: [
@@ -90,9 +95,11 @@ type AvailableForListOptions = {
90 ] 95 ]
91 } 96 }
92 97
93 if (withAccount === true) { 98 if (options.withAccount === true) {
94 base.include.push({ 99 base.include.push({
95 model: AccountModel.scope(AccountModelScopeNames.SUMMARY), 100 model: AccountModel.scope({
101 method: [ AccountModelScopeNames.SUMMARY, { withAccountBlockerIds: options.withAccountBlockerIds } as AccountSummaryOptions ]
102 }),
96 required: true 103 required: true
97 }) 104 })
98 } 105 }