]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video.ts
Merge branch 'release/v1.3.0' into develop
[github/Chocobozzz/PeerTube.git] / server / models / video / video.ts
index 18f18795ed653802d5cb9d82dde5ba067bf5b7b0..c0a7892a430f12f354671b6919c0e9edb54d0d07 100644 (file)
@@ -207,6 +207,8 @@ type AvailableForListIDsOptions = {
   followerActorId: number
   includeLocalVideos: boolean
 
+  withoutId?: boolean
+
   filter?: VideoFilter
   categoryOneOf?: number[]
   nsfw?: boolean
@@ -239,6 +241,11 @@ type AvailableForListIDsOptions = {
         {
           model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, true ] }),
           required: true
+        },
+        {
+          attributes: [ 'type', 'filename' ],
+          model: ThumbnailModel,
+          required: false
         }
       ]
     }
@@ -263,9 +270,11 @@ type AvailableForListIDsOptions = {
     return query
   },
   [ ScopeNames.AVAILABLE_FOR_LIST_IDS ]: (options: AvailableForListIDsOptions) => {
+    const attributes = options.withoutId === true ? [] : [ 'id' ]
+
     const query: FindOptions = {
       raw: true,
-      attributes: [ 'id' ],
+      attributes,
       where: {
         id: {
           [ Op.and ]: [
@@ -1117,15 +1126,11 @@ export class VideoModel extends Model<VideoModel> {
     const countQuery = buildBaseQuery()
     const findQuery = buildBaseQuery()
 
-    findQuery.include.push({
-      model: ScheduleVideoUpdateModel,
-      required: false
-    })
-
-    findQuery.include.push({
-      model: VideoBlacklistModel,
-      required: false
-    })
+    const findScopes = [
+      ScopeNames.WITH_SCHEDULED_UPDATE,
+      ScopeNames.WITH_BLACKLISTED,
+      ScopeNames.WITH_THUMBNAILS
+    ]
 
     if (withFiles === true) {
       findQuery.include.push({
@@ -1136,7 +1141,7 @@ export class VideoModel extends Model<VideoModel> {
 
     return Promise.all([
       VideoModel.count(countQuery),
-      VideoModel.findAll(findQuery)
+      VideoModel.scope(findScopes).findAll(findQuery)
     ]).then(([ count, rows ]) => {
       return {
         data: rows,
@@ -1518,7 +1523,8 @@ export class VideoModel extends Model<VideoModel> {
     const scopeOptions: AvailableForListIDsOptions = {
       serverAccountId: serverActor.Account.id,
       followerActorId,
-      includeLocalVideos: true
+      includeLocalVideos: true,
+      withoutId: true // Don't break aggregation
     }
 
     const query: FindOptions = {
@@ -1599,7 +1605,7 @@ export class VideoModel extends Model<VideoModel> {
       ]
     }
 
-    const apiScope: (string | ScopeOptions)[] = [ ScopeNames.WITH_THUMBNAILS ]
+    const apiScope: (string | ScopeOptions)[] = []
 
     if (options.user) {
       apiScope.push({ method: [ ScopeNames.WITH_USER_HISTORY, options.user.id ] })