X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-change-ownership.ts;h=2db4b523a654b6fda12274fed3f54dfe2325a7ff;hb=8c4bbd946d2247c2e239cbbf8773d2d31c1a57aa;hp=3259b6c0208d6b7b63d8739d3668c04257a99d8d;hpb=d7a25329f9e607894d29ab342b9cb66638b56dc0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-change-ownership.ts b/server/models/video/video-change-ownership.ts index 3259b6c02..2db4b523a 100644 --- a/server/models/video/video-change-ownership.ts +++ b/server/models/video/video-change-ownership.ts @@ -1,10 +1,10 @@ import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript' +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 '../shared' 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', @@ -46,14 +46,15 @@ enum ScopeNames { model: VideoModel.scope([ VideoScopeNames.WITH_THUMBNAILS, VideoScopeNames.WITH_WEBTORRENT_FILES, - VideoScopeNames.WITH_STREAMING_PLAYLISTS + VideoScopeNames.WITH_STREAMING_PLAYLISTS, + VideoScopeNames.WITH_ACCOUNT_DETAILS ]), required: true } ] } })) -export class VideoChangeOwnershipModel extends Model { +export class VideoChangeOwnershipModel extends Model>> { @CreatedAt createdAt: Date @@ -118,7 +119,7 @@ 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) } @@ -129,12 +130,7 @@ export class VideoChangeOwnershipModel extends Model 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 } }