aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-playlist.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index b9b95e067..d66518c9f 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -53,6 +53,7 @@ import {
53 MVideoPlaylistIdWithElements 53 MVideoPlaylistIdWithElements
54} from '../../typings/models/video/video-playlist' 54} from '../../typings/models/video/video-playlist'
55import { MThumbnail } from '../../typings/models/video/thumbnail' 55import { MThumbnail } from '../../typings/models/video/thumbnail'
56import { MAccountId, MChannelId } from '@server/typings/models'
56 57
57enum ScopeNames { 58enum ScopeNames {
58 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', 59 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST',
@@ -340,15 +341,24 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
340 }) 341 })
341 } 342 }
342 343
343 static listPublicUrlsOfForAP (accountId: number, start: number, count: number) { 344 static listPublicUrlsOfForAP (options: { account?: MAccountId, channel?: MChannelId }, start: number, count: number) {
345 const where = {
346 privacy: VideoPlaylistPrivacy.PUBLIC
347 }
348
349 if (options.account) {
350 Object.assign(where, { ownerAccountId: options.account.id })
351 }
352
353 if (options.channel) {
354 Object.assign(where, { videoChannelId: options.channel.id })
355 }
356
344 const query = { 357 const query = {
345 attributes: [ 'url' ], 358 attributes: [ 'url' ],
346 offset: start, 359 offset: start,
347 limit: count, 360 limit: count,
348 where: { 361 where
349 ownerAccountId: accountId,
350 privacy: VideoPlaylistPrivacy.PUBLIC
351 }
352 } 362 }
353 363
354 return VideoPlaylistModel.findAndCountAll(query) 364 return VideoPlaylistModel.findAndCountAll(query)