From cdeddff142fd20f8cb8bb346625909d61c596603 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Apr 2021 17:01:29 +0200 Subject: Add ability to update the banner --- server/models/account/actor-image.ts | 6 +++++- server/models/account/user.ts | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/actor-image.ts b/server/models/account/actor-image.ts index c532bd08d..b779e3cf6 100644 --- a/server/models/account/actor-image.ts +++ b/server/models/account/actor-image.ts @@ -72,7 +72,11 @@ export class ActorImageModel extends Model { } getStaticPath () { - return join(LAZY_STATIC_PATHS.AVATARS, this.filename) + if (this.type === ActorImageType.AVATAR) { + return join(LAZY_STATIC_PATHS.AVATARS, this.filename) + } + + return join(LAZY_STATIC_PATHS.BANNERS, this.filename) } getPath () { diff --git a/server/models/account/user.ts b/server/models/account/user.ts index a7a65c489..00c6d73aa 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -71,6 +71,7 @@ import { VideoLiveModel } from '../video/video-live' import { VideoPlaylistModel } from '../video/video-playlist' import { AccountModel } from './account' import { UserNotificationSettingModel } from './user-notification-setting' +import { ActorImageModel } from './actor-image' enum ScopeNames { FOR_ME_API = 'FOR_ME_API', @@ -97,7 +98,20 @@ enum ScopeNames { model: AccountModel, include: [ { - model: VideoChannelModel + model: VideoChannelModel.unscoped(), + include: [ + { + model: ActorModel, + required: true, + include: [ + { + model: ActorImageModel, + as: 'Banner', + required: false + } + ] + } + ] }, { attributes: [ 'id', 'name', 'type' ], -- cgit v1.2.3