From b64c950a1cb37da880fc14e8535f438c78b5b7f7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 12 Mar 2018 11:06:15 +0100 Subject: Update videos api list for account --- server/models/video/video.ts | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'server/models/video') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 1b9d68073..0e5dd0d2f 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -40,7 +40,8 @@ import { isVideoLanguageValid, isVideoLicenceValid, isVideoNameValid, - isVideoPrivacyValid, isVideoSupportValid + isVideoPrivacyValid, + isVideoSupportValid } from '../../helpers/custom-validators/videos' import { generateImageFromVideoFile, getVideoFileResolution, transcode } from '../../helpers/ffmpeg-utils' import { logger } from '../../helpers/logger' @@ -125,13 +126,18 @@ enum ScopeNames { required: true, include: [ { - attributes: [ 'serverId' ], + attributes: [ 'preferredUsername', 'url', 'serverId' ], model: ActorModel.unscoped(), required: true, include: [ { attributes: [ 'host' ], - model: ServerModel.unscoped() + model: ServerModel.unscoped(), + required: false + }, + { + model: AvatarModel.unscoped(), + required: false } ] } @@ -872,14 +878,7 @@ export class VideoModel extends Model { } toFormattedJSON (): Video { - let serverHost - - if (this.VideoChannel.Account.Actor.Server) { - serverHost = this.VideoChannel.Account.Actor.Server.host - } else { - // It means it's our video - serverHost = CONFIG.WEBSERVER.HOST - } + const formattedAccount = this.VideoChannel.Account.toFormattedJSON() return { id: this.id, @@ -893,9 +892,7 @@ export class VideoModel extends Model { languageLabel: this.getLanguageLabel(), nsfw: this.nsfw, description: this.getTruncatedDescription(), - serverHost, isLocal: this.isOwned(), - accountName: this.VideoChannel.Account.name, duration: this.duration, views: this.views, likes: this.likes, @@ -904,7 +901,14 @@ export class VideoModel extends Model { previewPath: this.getPreviewPath(), embedPath: this.getEmbedPath(), createdAt: this.createdAt, - updatedAt: this.updatedAt + updatedAt: this.updatedAt, + account: { + name: formattedAccount.name, + displayName: formattedAccount.displayName, + url: formattedAccount.url, + host: formattedAccount.host, + avatar: formattedAccount.avatar + } } } -- cgit v1.2.3