diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/models/video/video-channel.ts | 26 | ||||
-rw-r--r-- | server/tests/api/videos/video-channels.ts | 18 |
2 files changed, 31 insertions, 13 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 410fd6d3f..00ae58c68 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -143,28 +143,28 @@ export type SummaryOptions = { | |||
143 | }) | 143 | }) |
144 | } | 144 | } |
145 | 145 | ||
146 | const channelInclude: Includeable[] = [] | 146 | const channelActorInclude: Includeable[] = [] |
147 | const accountInclude: Includeable[] = [] | 147 | const accountActorInclude: Includeable[] = [] |
148 | 148 | ||
149 | if (options.forCount !== true) { | 149 | if (options.forCount !== true) { |
150 | accountInclude.push({ | 150 | accountActorInclude.push({ |
151 | model: ServerModel, | 151 | model: ServerModel, |
152 | required: false | 152 | required: false |
153 | }) | 153 | }) |
154 | 154 | ||
155 | accountInclude.push({ | 155 | accountActorInclude.push({ |
156 | model: ActorImageModel, | 156 | model: ActorImageModel, |
157 | as: 'Avatars', | 157 | as: 'Avatars', |
158 | required: false | 158 | required: false |
159 | }) | 159 | }) |
160 | 160 | ||
161 | channelInclude.push({ | 161 | channelActorInclude.push({ |
162 | model: ActorImageModel, | 162 | model: ActorImageModel, |
163 | as: 'Avatars', | 163 | as: 'Avatars', |
164 | required: false | 164 | required: false |
165 | }) | 165 | }) |
166 | 166 | ||
167 | channelInclude.push({ | 167 | channelActorInclude.push({ |
168 | model: ActorImageModel, | 168 | model: ActorImageModel, |
169 | as: 'Banners', | 169 | as: 'Banners', |
170 | required: false | 170 | required: false |
@@ -172,7 +172,7 @@ export type SummaryOptions = { | |||
172 | } | 172 | } |
173 | 173 | ||
174 | if (options.forCount !== true || serverRequired) { | 174 | if (options.forCount !== true || serverRequired) { |
175 | channelInclude.push({ | 175 | channelActorInclude.push({ |
176 | model: ServerModel, | 176 | model: ServerModel, |
177 | duplicating: false, | 177 | duplicating: false, |
178 | required: serverRequired, | 178 | required: serverRequired, |
@@ -190,7 +190,7 @@ export type SummaryOptions = { | |||
190 | where: { | 190 | where: { |
191 | [Op.and]: whereActorAnd | 191 | [Op.and]: whereActorAnd |
192 | }, | 192 | }, |
193 | include: channelInclude | 193 | include: channelActorInclude |
194 | }, | 194 | }, |
195 | { | 195 | { |
196 | model: AccountModel.unscoped(), | 196 | model: AccountModel.unscoped(), |
@@ -202,7 +202,7 @@ export type SummaryOptions = { | |||
202 | }, | 202 | }, |
203 | model: ActorModel.unscoped(), | 203 | model: ActorModel.unscoped(), |
204 | required: true, | 204 | required: true, |
205 | include: accountInclude | 205 | include: accountActorInclude |
206 | } | 206 | } |
207 | ] | 207 | ] |
208 | } | 208 | } |
@@ -605,17 +605,17 @@ ON "Account->Actor"."serverId" = "Account->Actor->Server"."id"` | |||
605 | } | 605 | } |
606 | } | 606 | } |
607 | 607 | ||
608 | const scopes: string | ScopeOptions | (string | ScopeOptions)[] = [ ScopeNames.WITH_ACTOR_BANNER ] | 608 | const findScopes: string | ScopeOptions | (string | ScopeOptions)[] = [ ScopeNames.WITH_ACTOR_BANNER ] |
609 | 609 | ||
610 | if (options.withStats === true) { | 610 | if (options.withStats === true) { |
611 | scopes.push({ | 611 | findScopes.push({ |
612 | method: [ ScopeNames.WITH_STATS, { daysPrior: 30 } as AvailableWithStatsOptions ] | 612 | method: [ ScopeNames.WITH_STATS, { daysPrior: 30 } as AvailableWithStatsOptions ] |
613 | }) | 613 | }) |
614 | } | 614 | } |
615 | 615 | ||
616 | return Promise.all([ | 616 | return Promise.all([ |
617 | VideoChannelModel.scope(scopes).count(getQuery(true)), | 617 | VideoChannelModel.unscoped().count(getQuery(true)), |
618 | VideoChannelModel.scope(scopes).findAll(getQuery(false)) | 618 | VideoChannelModel.scope(findScopes).findAll(getQuery(false)) |
619 | ]).then(([ total, data ]) => ({ total, data })) | 619 | ]).then(([ total, data ]) => ({ total, data })) |
620 | } | 620 | } |
621 | 621 | ||
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 0f8227fd3..09a4bfa70 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -325,6 +325,24 @@ describe('Test video channels', function () { | |||
325 | } | 325 | } |
326 | }) | 326 | }) |
327 | 327 | ||
328 | it('Should still correctly list channels', async function () { | ||
329 | { | ||
330 | const body = await servers[0].channels.list({ start: 1, count: 1, sort: 'createdAt' }) | ||
331 | |||
332 | expect(body.total).to.equal(3) | ||
333 | expect(body.data).to.have.lengthOf(1) | ||
334 | expect(body.data[0].name).to.equal('second_video_channel') | ||
335 | } | ||
336 | |||
337 | { | ||
338 | const body = await servers[0].channels.listByAccount({ accountName, start: 1, count: 1, sort: 'createdAt' }) | ||
339 | |||
340 | expect(body.total).to.equal(2) | ||
341 | expect(body.data).to.have.lengthOf(1) | ||
342 | expect(body.data[0].name).to.equal('second_video_channel') | ||
343 | } | ||
344 | }) | ||
345 | |||
328 | it('Should delete the video channel avatar', async function () { | 346 | it('Should delete the video channel avatar', async function () { |
329 | this.timeout(15000) | 347 | this.timeout(15000) |
330 | await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' }) | 348 | await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' }) |