aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-12 11:06:15 +0100
committerChocobozzz <me@florianbigard.com>2018-03-12 11:44:28 +0100
commitb64c950a1cb37da880fc14e8535f438c78b5b7f7 (patch)
tree713bcba3c36e8b13345f0d7134d2e2876265b8e2 /server/models/video
parent416c359cb5967c2b5dff0909ef5558a49d753a1a (diff)
downloadPeerTube-b64c950a1cb37da880fc14e8535f438c78b5b7f7.tar.gz
PeerTube-b64c950a1cb37da880fc14e8535f438c78b5b7f7.tar.zst
PeerTube-b64c950a1cb37da880fc14e8535f438c78b5b7f7.zip
Update videos api list for account
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