]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-change-ownership.ts
Search typeahead initial design
[github/Chocobozzz/PeerTube.git] / server / models / video / video-change-ownership.ts
index b545a2f8c9528f67bd6a262cb61bd9e3a72a427f..3259b6c0208d6b7b63d8739d3668c04257a99d8d 100644 (file)
@@ -3,6 +3,8 @@ import { AccountModel } from '../account/account'
 import { ScopeNames as VideoScopeNames, VideoModel } from './video'
 import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos'
 import { getSort } from '../utils'
+import { MVideoChangeOwnershipFormattable, MVideoChangeOwnershipFull } from '@server/typings/models/video/video-change-ownership'
+import * as Bluebird from 'bluebird'
 
 enum ScopeNames {
   WITH_ACCOUNTS = 'WITH_ACCOUNTS',
@@ -41,7 +43,11 @@ enum ScopeNames {
   [ScopeNames.WITH_VIDEO]: {
     include: [
       {
-        model: VideoModel.scope([ VideoScopeNames.WITH_THUMBNAILS, VideoScopeNames.WITH_FILES ]),
+        model: VideoModel.scope([
+          VideoScopeNames.WITH_THUMBNAILS,
+          VideoScopeNames.WITH_WEBTORRENT_FILES,
+          VideoScopeNames.WITH_STREAMING_PLAYLISTS
+        ]),
         required: true
       }
     ]
@@ -108,16 +114,16 @@ export class VideoChangeOwnershipModel extends Model<VideoChangeOwnershipModel>
 
     return Promise.all([
       VideoChangeOwnershipModel.scope(ScopeNames.WITH_ACCOUNTS).count(query),
-      VideoChangeOwnershipModel.scope([ ScopeNames.WITH_ACCOUNTS, ScopeNames.WITH_VIDEO ]).findAll(query)
+      VideoChangeOwnershipModel.scope([ ScopeNames.WITH_ACCOUNTS, ScopeNames.WITH_VIDEO ]).findAll<MVideoChangeOwnershipFull>(query)
     ]).then(([ count, rows ]) => ({ total: count, data: rows }))
   }
 
-  static load (id: number) {
+  static load (id: number): Bluebird<MVideoChangeOwnershipFull> {
     return VideoChangeOwnershipModel.scope([ ScopeNames.WITH_ACCOUNTS, ScopeNames.WITH_VIDEO ])
                                     .findByPk(id)
   }
 
-  toFormattedJSON (): VideoChangeOwnership {
+  toFormattedJSON (this: MVideoChangeOwnershipFormattable): VideoChangeOwnership {
     return {
       id: this.id,
       status: this.status,