From 7405b6ba897dbce1b4fd50c92174f1df5ac15adc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 13 May 2020 14:49:11 +0200 Subject: Add missing channel playlists AP endpoint --- server/models/video/video-playlist.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'server/models/video') 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 { MVideoPlaylistIdWithElements } from '../../typings/models/video/video-playlist' import { MThumbnail } from '../../typings/models/video/thumbnail' +import { MAccountId, MChannelId } from '@server/typings/models' enum ScopeNames { AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', @@ -340,15 +341,24 @@ export class VideoPlaylistModel extends Model { }) } - static listPublicUrlsOfForAP (accountId: number, start: number, count: number) { + static listPublicUrlsOfForAP (options: { account?: MAccountId, channel?: MChannelId }, start: number, count: number) { + const where = { + privacy: VideoPlaylistPrivacy.PUBLIC + } + + if (options.account) { + Object.assign(where, { ownerAccountId: options.account.id }) + } + + if (options.channel) { + Object.assign(where, { videoChannelId: options.channel.id }) + } + const query = { attributes: [ 'url' ], offset: start, limit: count, - where: { - ownerAccountId: accountId, - privacy: VideoPlaylistPrivacy.PUBLIC - } + where } return VideoPlaylistModel.findAndCountAll(query) -- cgit v1.2.3