]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-playlist.ts
Merge branch 'release/2.3.0' into develop
[github/Chocobozzz/PeerTube.git] / server / models / video / video-playlist.ts
index b9b95e06719ba6bb5bb126555bbbd34e9b377c50..51fe04fc487a1627c3c0459cb3ab1974f231ae47 100644 (file)
@@ -51,8 +51,9 @@ import {
   MVideoPlaylistFull,
   MVideoPlaylistFullSummary,
   MVideoPlaylistIdWithElements
-} from '../../typings/models/video/video-playlist'
-import { MThumbnail } from '../../typings/models/video/thumbnail'
+} from '../../types/models/video/video-playlist'
+import { MThumbnail } from '../../types/models/video/thumbnail'
+import { MAccountId, MChannelId } from '@server/types/models'
 
 enum ScopeNames {
   AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST',
@@ -340,15 +341,24 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
       })
   }
 
-  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)