X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-change-ownership.ts;h=298e8bfe2233dca0972d78ea62b6d814837dbd5d;hb=90a8bd305de4153ec21137a73ff482dcc2e3e19b;hp=2d0ff48fb212e608fac91f4e729dd17b084e4794;hpb=453e83ea5d81d203ba34bc43cd5c2c750ba40568;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.ts index 2d0ff48fb..298e8bfe2 100644 --- a/server/models/video/video-change-ownership.ts +++ b/server/models/video/video-change-ownership.ts @@ -1,10 +1,9 @@ import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' -import { AccountModel } from '../account/account' -import { ScopeNames as VideoScopeNames, VideoModel } from './video' +import { MVideoChangeOwnershipFormattable, MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos' +import { AccountModel } from '../account/account' import { getSort } from '../utils' -import { MVideoChangeOwnershipFull } from '@server/typings/models/video/video-change-ownership' -import * as Bluebird from 'bluebird' +import { ScopeNames as VideoScopeNames, VideoModel } from './video' enum ScopeNames { WITH_ACCOUNTS = 'WITH_ACCOUNTS', @@ -43,13 +42,18 @@ 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, + VideoScopeNames.WITH_ACCOUNT_DETAILS + ]), required: true } ] } })) -export class VideoChangeOwnershipModel extends Model { +export class VideoChangeOwnershipModel extends Model { @CreatedAt createdAt: Date @@ -114,23 +118,18 @@ export class VideoChangeOwnershipModel extends Model ]).then(([ count, rows ]) => ({ total: count, data: rows })) } - static load (id: number): Bluebird { + static load (id: number): Promise { return VideoChangeOwnershipModel.scope([ ScopeNames.WITH_ACCOUNTS, ScopeNames.WITH_VIDEO ]) .findByPk(id) } - toFormattedJSON (): VideoChangeOwnership { + toFormattedJSON (this: MVideoChangeOwnershipFormattable): VideoChangeOwnership { return { id: this.id, status: this.status, initiatorAccount: this.Initiator.toFormattedJSON(), nextOwnerAccount: this.NextOwner.toFormattedJSON(), - video: { - id: this.Video.id, - uuid: this.Video.uuid, - url: this.Video.url, - name: this.Video.name - }, + video: this.Video.toFormattedJSON(), createdAt: this.createdAt } }