X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-change-ownership.ts;h=1a1b8c88de203e55dbff3e1f11f02ab7d351a069;hb=dbd9fb44ddd880622265097bd7baf4dd71ea0861;hp=b545a2f8c9528f67bd6a262cb61bd9e3a72a427f;hpb=97567dd81f508dd6295ac4d73d849aa2ce0a6549;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.ts index b545a2f8c..1a1b8c88d 100644 --- a/server/models/video/video-change-ownership.ts +++ b/server/models/video/video-change-ownership.ts @@ -1,8 +1,10 @@ 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 { AttributesOnly } from '@shared/typescript-utils' import { VideoChangeOwnership, VideoChangeOwnershipStatus } from '../../../shared/models/videos' +import { AccountModel } from '../account/account' import { getSort } from '../utils' +import { ScopeNames as VideoScopeNames, VideoModel } from './video' enum ScopeNames { WITH_ACCOUNTS = 'WITH_ACCOUNTS', @@ -41,13 +43,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 @@ -108,27 +115,22 @@ export class VideoChangeOwnershipModel extends Model 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(query) ]).then(([ count, rows ]) => ({ total: count, data: rows })) } - static load (id: number) { + 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 } }