]> 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 5fb529e8d113455c54c60b4413bb2802ca2bc252..c0a7892a430f12f354671b6919c0e9edb54d0d07 100644 (file)
@@ -207,6 +207,8 @@ type AvailableForListIDsOptions = {
   followerActorId: number
   includeLocalVideos: boolean
 
+  withoutId?: boolean
+
   filter?: VideoFilter
   categoryOneOf?: number[]
   nsfw?: boolean
@@ -268,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 ]: [
@@ -1122,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({
@@ -1141,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,
@@ -1523,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 = {