aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-11 15:10:13 +0200
committerChocobozzz <me@florianbigard.com>2018-05-11 15:25:51 +0200
commit0f320037e689b2778959c12ddd4ce790f6e4ae4f (patch)
tree425acaa4345442388901c833275bb76b42a8a268 /server/lib/activitypub/videos.ts
parent9675333decd0b89b73a4fc67b39272f7296bfe3f (diff)
downloadPeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.tar.gz
PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.tar.zst
PeerTube-0f320037e689b2778959c12ddd4ce790f6e4ae4f.zip
Add ability to update a video channel
Diffstat (limited to 'server/lib/activitypub/videos.ts')
-rw-r--r--server/lib/activitypub/videos.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index b81acbb35..2899acff3 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -137,6 +137,13 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje
137 return attributes 137 return attributes
138} 138}
139 139
140function getOrCreateVideoChannel (videoObject: VideoTorrentObject) {
141 const channel = videoObject.attributedTo.find(a => a.type === 'Group')
142 if (!channel) throw new Error('Cannot find associated video channel to video ' + videoObject.url)
143
144 return getOrCreateActorAndServerAndModel(channel.id)
145}
146
140async function getOrCreateVideo (videoObject: VideoTorrentObject, channelActor: ActorModel) { 147async function getOrCreateVideo (videoObject: VideoTorrentObject, channelActor: ActorModel) {
141 logger.debug('Adding remote video %s.', videoObject.id) 148 logger.debug('Adding remote video %s.', videoObject.id)
142 149
@@ -199,10 +206,7 @@ async function getOrCreateAccountAndVideoAndChannel (videoObject: VideoTorrentOb
199 actor = await getOrCreateActorAndServerAndModel(actorObj.id) 206 actor = await getOrCreateActorAndServerAndModel(actorObj.id)
200 } 207 }
201 208
202 const channel = videoObject.attributedTo.find(a => a.type === 'Group') 209 const channelActor = await getOrCreateVideoChannel(videoObject)
203 if (!channel) throw new Error('Cannot find associated video channel to video ' + videoObject.url)
204
205 const channelActor = await getOrCreateActorAndServerAndModel(channel.id)
206 210
207 const options = { 211 const options = {
208 arguments: [ videoObject, channelActor ], 212 arguments: [ videoObject, channelActor ],
@@ -301,6 +305,7 @@ export {
301 videoActivityObjectToDBAttributes, 305 videoActivityObjectToDBAttributes,
302 videoFileActivityUrlToDBAttributes, 306 videoFileActivityUrlToDBAttributes,
303 getOrCreateVideo, 307 getOrCreateVideo,
308 getOrCreateVideoChannel,
304 addVideoShares} 309 addVideoShares}
305 310
306// --------------------------------------------------------------------------- 311// ---------------------------------------------------------------------------