Fix thumbnail when listing my videos
authorChocobozzz <me@florianbigard.com>
Fri, 26 Apr 2019 08:20:58 +0000 (10:20 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 13 May 2019 07:45:36 +0000 (09:45 +0200)
server/models/video/video.ts
server/tests/api/users/users.ts

index 4e6f602aa8bdfce12b4db4f9c4aab4ad5159ade6..c0a7892a430f12f354671b6919c0e9edb54d0d07 100644 (file)
@@ -1126,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({
@@ -1145,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,
index e7291740ba596e117bb52b68c0859cad0a24b6f3..c8e32f3f55b0b368f782e1701edcd7ffef3c622f 100644 (file)
@@ -2,7 +2,7 @@
 
 import * as chai from 'chai'
 import 'mocha'
-import { User, UserRole } from '../../../../shared/index'
+import { User, UserRole, Video } from '../../../../shared/index'
 import {
   blockUser,
   cleanupTests,
@@ -290,7 +290,10 @@ describe('Test users', function () {
       const videos = res.body.data
       expect(videos).to.have.lengthOf(1)
 
-      expect(videos[ 0 ].name).to.equal('super user video')
+      const video: Video = videos[ 0 ]
+      expect(video.name).to.equal('super user video')
+      expect(video.thumbnailPath).to.not.be.null
+      expect(video.previewPath).to.not.be.null
     })
   })