aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video.ts32
1 files changed, 18 insertions, 14 deletions
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 {
40 isVideoLanguageValid, 40 isVideoLanguageValid,
41 isVideoLicenceValid, 41 isVideoLicenceValid,
42 isVideoNameValid, 42 isVideoNameValid,
43 isVideoPrivacyValid, isVideoSupportValid 43 isVideoPrivacyValid,
44 isVideoSupportValid
44} from '../../helpers/custom-validators/videos' 45} from '../../helpers/custom-validators/videos'
45import { generateImageFromVideoFile, getVideoFileResolution, transcode } from '../../helpers/ffmpeg-utils' 46import { generateImageFromVideoFile, getVideoFileResolution, transcode } from '../../helpers/ffmpeg-utils'
46import { logger } from '../../helpers/logger' 47import { logger } from '../../helpers/logger'
@@ -125,13 +126,18 @@ enum ScopeNames {
125 required: true, 126 required: true,
126 include: [ 127 include: [
127 { 128 {
128 attributes: [ 'serverId' ], 129 attributes: [ 'preferredUsername', 'url', 'serverId' ],
129 model: ActorModel.unscoped(), 130 model: ActorModel.unscoped(),
130 required: true, 131 required: true,
131 include: [ 132 include: [
132 { 133 {
133 attributes: [ 'host' ], 134 attributes: [ 'host' ],
134 model: ServerModel.unscoped() 135 model: ServerModel.unscoped(),
136 required: false
137 },
138 {
139 model: AvatarModel.unscoped(),
140 required: false
135 } 141 }
136 ] 142 ]
137 } 143 }
@@ -872,14 +878,7 @@ export class VideoModel extends Model<VideoModel> {
872 } 878 }
873 879
874 toFormattedJSON (): Video { 880 toFormattedJSON (): Video {
875 let serverHost 881 const formattedAccount = this.VideoChannel.Account.toFormattedJSON()
876
877 if (this.VideoChannel.Account.Actor.Server) {
878 serverHost = this.VideoChannel.Account.Actor.Server.host
879 } else {
880 // It means it's our video
881 serverHost = CONFIG.WEBSERVER.HOST
882 }
883 882
884 return { 883 return {
885 id: this.id, 884 id: this.id,
@@ -893,9 +892,7 @@ export class VideoModel extends Model<VideoModel> {
893 languageLabel: this.getLanguageLabel(), 892 languageLabel: this.getLanguageLabel(),
894 nsfw: this.nsfw, 893 nsfw: this.nsfw,
895 description: this.getTruncatedDescription(), 894 description: this.getTruncatedDescription(),
896 serverHost,
897 isLocal: this.isOwned(), 895 isLocal: this.isOwned(),
898 accountName: this.VideoChannel.Account.name,
899 duration: this.duration, 896 duration: this.duration,
900 views: this.views, 897 views: this.views,
901 likes: this.likes, 898 likes: this.likes,
@@ -904,7 +901,14 @@ export class VideoModel extends Model<VideoModel> {
904 previewPath: this.getPreviewPath(), 901 previewPath: this.getPreviewPath(),
905 embedPath: this.getEmbedPath(), 902 embedPath: this.getEmbedPath(),
906 createdAt: this.createdAt, 903 createdAt: this.createdAt,
907 updatedAt: this.updatedAt 904 updatedAt: this.updatedAt,
905 account: {
906 name: formattedAccount.name,
907 displayName: formattedAccount.displayName,
908 url: formattedAccount.url,
909 host: formattedAccount.host,
910 avatar: formattedAccount.avatar
911 }
908 } 912 }
909 } 913 }
910 914