diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-11 15:10:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-11 15:25:51 +0200 |
commit | 0f320037e689b2778959c12ddd4ce790f6e4ae4f (patch) | |
tree | 425acaa4345442388901c833275bb76b42a8a268 /server/models/video/video.ts | |
parent | 9675333decd0b89b73a4fc67b39272f7296bfe3f (diff) | |
download | PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.tar.gz PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.tar.zst PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.zip |
Add ability to update a video channel
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index ea466fccd..fe8c30655 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -130,11 +130,27 @@ enum ScopeNames { | |||
130 | } | 130 | } |
131 | 131 | ||
132 | const videoChannelInclude = { | 132 | const videoChannelInclude = { |
133 | attributes: [ 'name', 'description' ], | 133 | attributes: [ 'name', 'description', 'id' ], |
134 | model: VideoChannelModel.unscoped(), | 134 | model: VideoChannelModel.unscoped(), |
135 | required: true, | 135 | required: true, |
136 | where: {}, | 136 | where: {}, |
137 | include: [ | 137 | include: [ |
138 | { | ||
139 | attributes: [ 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ], | ||
140 | model: ActorModel.unscoped(), | ||
141 | required: true, | ||
142 | include: [ | ||
143 | { | ||
144 | attributes: [ 'host' ], | ||
145 | model: ServerModel.unscoped(), | ||
146 | required: false | ||
147 | }, | ||
148 | { | ||
149 | model: AvatarModel.unscoped(), | ||
150 | required: false | ||
151 | } | ||
152 | ] | ||
153 | }, | ||
138 | accountInclude | 154 | accountInclude |
139 | ] | 155 | ] |
140 | } | 156 | } |
@@ -771,12 +787,17 @@ export class VideoModel extends Model<VideoModel> { | |||
771 | } | 787 | } |
772 | }, | 788 | }, |
773 | { | 789 | { |
774 | preferredUsername: Sequelize.where(Sequelize.col('preferredUsername'), { | 790 | preferredUsernameChannel: Sequelize.where(Sequelize.col('VideoChannel->Actor.preferredUsername'), { |
775 | [ Sequelize.Op.iLike ]: '%' + value + '%' | 791 | [ Sequelize.Op.iLike ]: '%' + value + '%' |
776 | }) | 792 | }) |
777 | }, | 793 | }, |
778 | { | 794 | { |
779 | host: Sequelize.where(Sequelize.col('host'), { | 795 | preferredUsernameAccount: Sequelize.where(Sequelize.col('VideoChannel->Account->Actor.preferredUsername'), { |
796 | [ Sequelize.Op.iLike ]: '%' + value + '%' | ||
797 | }) | ||
798 | }, | ||
799 | { | ||
800 | host: Sequelize.where(Sequelize.col('VideoChannel->Account->Actor->Server.host'), { | ||
780 | [ Sequelize.Op.iLike ]: '%' + value + '%' | 801 | [ Sequelize.Op.iLike ]: '%' + value + '%' |
781 | }) | 802 | }) |
782 | } | 803 | } |
@@ -1043,6 +1064,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1043 | 1064 | ||
1044 | toFormattedJSON (): Video { | 1065 | toFormattedJSON (): Video { |
1045 | const formattedAccount = this.VideoChannel.Account.toFormattedJSON() | 1066 | const formattedAccount = this.VideoChannel.Account.toFormattedJSON() |
1067 | const formattedVideoChannel = this.VideoChannel.toFormattedJSON() | ||
1046 | 1068 | ||
1047 | return { | 1069 | return { |
1048 | id: this.id, | 1070 | id: this.id, |
@@ -1085,6 +1107,15 @@ export class VideoModel extends Model<VideoModel> { | |||
1085 | url: formattedAccount.url, | 1107 | url: formattedAccount.url, |
1086 | host: formattedAccount.host, | 1108 | host: formattedAccount.host, |
1087 | avatar: formattedAccount.avatar | 1109 | avatar: formattedAccount.avatar |
1110 | }, | ||
1111 | channel: { | ||
1112 | id: formattedVideoChannel.id, | ||
1113 | uuid: formattedVideoChannel.uuid, | ||
1114 | name: formattedVideoChannel.name, | ||
1115 | displayName: formattedVideoChannel.displayName, | ||
1116 | url: formattedVideoChannel.url, | ||
1117 | host: formattedVideoChannel.host, | ||
1118 | avatar: formattedVideoChannel.avatar | ||
1088 | } | 1119 | } |
1089 | } | 1120 | } |
1090 | } | 1121 | } |