diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-31 15:57:32 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-08-01 09:11:04 +0200 |
commit | bfbd912886eba17b4aa9a40dcef2fddc685d85bf (patch) | |
tree | 85e0f22980210a8ccd0888eb5e1790b152074677 /server/models/video/video-channel.ts | |
parent | 85394ba22a07bde1dfccebf3f591a5d6dbe9df56 (diff) | |
download | PeerTube-bfbd912886eba17b4aa9a40dcef2fddc685d85bf.tar.gz PeerTube-bfbd912886eba17b4aa9a40dcef2fddc685d85bf.tar.zst PeerTube-bfbd912886eba17b4aa9a40dcef2fddc685d85bf.zip |
Fix broken playlist api
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r-- | server/models/video/video-channel.ts | 15 |
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' |
26 | import { sendDeleteActor } from '../../lib/activitypub/send' | 26 | import { sendDeleteActor } from '../../lib/activitypub/send' |
27 | import { AccountModel, ScopeNames as AccountModelScopeNames } from '../account/account' | 27 | import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account' |
28 | import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' | 28 | import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor' |
29 | import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' | 29 | import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils' |
30 | import { VideoModel } from './video' | 30 | import { VideoModel } from './video' |
@@ -58,6 +58,11 @@ type AvailableForListOptions = { | |||
58 | actorId: number | 58 | actorId: number |
59 | } | 59 | } |
60 | 60 | ||
61 | export 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 | } |