diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 14:44:51 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:53 +0100 |
commit | 4e50b6a1c9a3eb261e04ede73241648e6edf21d6 (patch) | |
tree | e1c6c121d561ffc1cf2996daec03a1e7f27f0a25 /server/models/video/video-channel.ts | |
parent | 74bb2cb8348d6794ed3a0e2ec94c8c9abdde82cf (diff) | |
download | PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.gz PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.tar.zst PeerTube-4e50b6a1c9a3eb261e04ede73241648e6edf21d6.zip |
Add shares forward and collection on videos/video channels
Diffstat (limited to 'server/models/video/video-channel.ts')
-rw-r--r-- | server/models/video/video-channel.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/server/models/video/video-channel.ts b/server/models/video/video-channel.ts index 64130310d..e11268b2c 100644 --- a/server/models/video/video-channel.ts +++ b/server/models/video/video-channel.ts | |||
@@ -6,6 +6,8 @@ import { sendDeleteVideoChannel } from '../../lib/activitypub/send/send-delete' | |||
6 | 6 | ||
7 | import { addMethodsToModel, getSort } from '../utils' | 7 | import { addMethodsToModel, getSort } from '../utils' |
8 | import { VideoChannelAttributes, VideoChannelInstance, VideoChannelMethods } from './video-channel-interface' | 8 | import { VideoChannelAttributes, VideoChannelInstance, VideoChannelMethods } from './video-channel-interface' |
9 | import { getAnnounceActivityPubUrl } from '../../lib/activitypub/url' | ||
10 | import { activityPubCollection } from '../../helpers/activitypub' | ||
9 | 11 | ||
10 | let VideoChannel: Sequelize.Model<VideoChannelInstance, VideoChannelAttributes> | 12 | let VideoChannel: Sequelize.Model<VideoChannelInstance, VideoChannelAttributes> |
11 | let toFormattedJSON: VideoChannelMethods.ToFormattedJSON | 13 | let toFormattedJSON: VideoChannelMethods.ToFormattedJSON |
@@ -139,6 +141,18 @@ toFormattedJSON = function (this: VideoChannelInstance) { | |||
139 | } | 141 | } |
140 | 142 | ||
141 | toActivityPubObject = function (this: VideoChannelInstance) { | 143 | toActivityPubObject = function (this: VideoChannelInstance) { |
144 | let sharesObject | ||
145 | if (Array.isArray(this.VideoChannelShares)) { | ||
146 | const shares: string[] = [] | ||
147 | |||
148 | for (const videoChannelShare of this.VideoChannelShares) { | ||
149 | const shareUrl = getAnnounceActivityPubUrl(this.url, videoChannelShare.Account) | ||
150 | shares.push(shareUrl) | ||
151 | } | ||
152 | |||
153 | sharesObject = activityPubCollection(shares) | ||
154 | } | ||
155 | |||
142 | const json = { | 156 | const json = { |
143 | type: 'VideoChannel' as 'VideoChannel', | 157 | type: 'VideoChannel' as 'VideoChannel', |
144 | id: this.url, | 158 | id: this.url, |
@@ -146,7 +160,8 @@ toActivityPubObject = function (this: VideoChannelInstance) { | |||
146 | content: this.description, | 160 | content: this.description, |
147 | name: this.name, | 161 | name: this.name, |
148 | published: this.createdAt.toISOString(), | 162 | published: this.createdAt.toISOString(), |
149 | updated: this.updatedAt.toISOString() | 163 | updated: this.updatedAt.toISOString(), |
164 | shares: sharesObject | ||
150 | } | 165 | } |
151 | 166 | ||
152 | return json | 167 | return json |