X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fvideo%2Fvideo-channel.ts;h=4251afce994d00ab7999b2fb92420b36b8d7bec1;hb=f4001cf408a99049d01a356bfb20a62342de06ea;hp=8498143fe33b7d5c4781532bbcb0fd68cfd8b326;hpb=a10fc78bb0e00e98c8f59edc16cd323b9c8b0615;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 8498143fe..4251afce9 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts @@ -15,6 +15,7 @@ import { ActorModel } from '../activitypub/actor' import { getSort, throwIfNotValid } from '../utils' import { VideoModel } from './video' import { CONSTRAINTS_FIELDS } from '../../initializers' +import { AvatarModel } from '../avatar/avatar' enum ScopeNames { WITH_ACCOUNT = 'WITH_ACCOUNT', @@ -34,12 +35,18 @@ enum ScopeNames { [ScopeNames.WITH_ACCOUNT]: { include: [ { - model: () => AccountModel, + model: () => AccountModel.unscoped(), required: true, include: [ { - model: () => ActorModel, - required: true + model: () => ActorModel.unscoped(), + required: true, + include: [ + { + model: () => AvatarModel.unscoped(), + required: false + } + ] } ] } @@ -237,7 +244,7 @@ export class VideoChannelModel extends Model { const actor = this.Actor.toFormattedJSON() const videoChannel = { id: this.id, - displayName: this.name, + displayName: this.getDisplayName(), description: this.description, support: this.support, isLocal: this.Actor.isOwned(), @@ -247,12 +254,7 @@ export class VideoChannelModel extends Model { videos: undefined } - if (this.Account) { - videoChannel.ownerAccount = { - id: this.Account.id, - uuid: this.Account.Actor.uuid - } - } + if (this.Account) videoChannel.ownerAccount = this.Account.toFormattedJSON() return Object.assign(actor, videoChannel) } @@ -271,4 +273,8 @@ export class VideoChannelModel extends Model { ] }) } + + getDisplayName () { + return this.name + } }