X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-channel.ts;h=4a50af265fae906a65f0e060688ef7f1b70ffb7c;hb=6b738c7a31591a83fdcd9c78b6b1f98e543c378b;hp=289775a0f93312d42e3149bf1c965983ebad04cb;hpb=2422c46b27790d94fd29a7092170cee5a1b56008;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 289775a0f..4a50af265 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -108,7 +108,7 @@ export class VideoChannelModel extends Model { foreignKey: { allowNull: false }, - onDelete: 'CASCADE' + hooks: true }) Account: AccountModel @@ -151,7 +151,7 @@ export class VideoChannelModel extends Model { const query = { offset: start, limit: count, - order: [ getSort(sort) ] + order: getSort(sort) } return VideoChannelModel @@ -164,7 +164,7 @@ export class VideoChannelModel extends Model { static listByAccount (accountId: number) { const query = { - order: [ getSort('createdAt') ], + order: getSort('createdAt'), include: [ { model: AccountModel, @@ -234,17 +234,26 @@ export class VideoChannelModel extends Model { toFormattedJSON (): VideoChannel { const actor = this.Actor.toFormattedJSON() - const account = { + const videoChannel = { id: this.id, displayName: this.name, description: this.description, support: this.support, isLocal: this.Actor.isOwned(), createdAt: this.createdAt, - updatedAt: this.updatedAt + updatedAt: this.updatedAt, + ownerAccount: undefined, + videos: undefined + } + + if (this.Account) { + videoChannel.ownerAccount = { + id: this.Account.id, + uuid: this.Account.Actor.uuid + } } - return Object.assign(actor, account) + return Object.assign(actor, videoChannel) } toActivityPubObject (): ActivityPubActor {