diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-13 14:49:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-05-13 14:49:11 +0200 |
commit | 7405b6ba897dbce1b4fd50c92174f1df5ac15adc (patch) | |
tree | 88816a1e713801e06ec50fb98c4bb3d05b612d1c /server/models | |
parent | 63748ad00517022de1d89f9dc3003135b2f10629 (diff) | |
download | PeerTube-7405b6ba897dbce1b4fd50c92174f1df5ac15adc.tar.gz PeerTube-7405b6ba897dbce1b4fd50c92174f1df5ac15adc.tar.zst PeerTube-7405b6ba897dbce1b4fd50c92174f1df5ac15adc.zip |
Add missing channel playlists AP endpoint
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/video/video-playlist.ts | 20 |
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' |
55 | import { MThumbnail } from '../../typings/models/video/thumbnail' | 55 | import { MThumbnail } from '../../typings/models/video/thumbnail' |
56 | import { MAccountId, MChannelId } from '@server/typings/models' | ||
56 | 57 | ||
57 | enum ScopeNames { | 58 | enum 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) |