aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-22 17:08:02 +0100
committerChocobozzz <me@florianbigard.com>2018-03-22 17:12:25 +0100
commit296c090563f9d609d3c55dec378a3a1d65c4bd78 (patch)
tree241ed8a3b49ef536abb06152a2bcfdeb6408fc42 /server/controllers/activitypub
parentbebf2d89d335c48659d2e25cb9f6f8310e867fc5 (diff)
downloadPeerTube-296c090563f9d609d3c55dec378a3a1d65c4bd78.tar.gz
PeerTube-296c090563f9d609d3c55dec378a3a1d65c4bd78.tar.zst
PeerTube-296c090563f9d609d3c55dec378a3a1d65c4bd78.zip
Add activity route to video and video comment objects
Diffstat (limited to 'server/controllers/activitypub')
-rw-r--r--server/controllers/activitypub/client.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index 55bd85c48..347079816 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -6,6 +6,7 @@ import { pageToStartAndCount } from '../../helpers/core-utils'
6import { ACTIVITY_PUB, CONFIG } from '../../initializers' 6import { ACTIVITY_PUB, CONFIG } from '../../initializers'
7import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' 7import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send'
8import { audiencify, getAudience } from '../../lib/activitypub/send/misc' 8import { audiencify, getAudience } from '../../lib/activitypub/send/misc'
9import { createActivityData } from '../../lib/activitypub/send/send-create'
9import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' 10import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares'
10import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators' 11import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators'
11import { videoCommentGetValidator } from '../../middlewares/validators/video-comments' 12import { videoCommentGetValidator } from '../../middlewares/validators/video-comments'
@@ -36,6 +37,10 @@ activityPubClientRouter.get('/videos/watch/:id',
36 executeIfActivityPub(asyncMiddleware(videosGetValidator)), 37 executeIfActivityPub(asyncMiddleware(videosGetValidator)),
37 executeIfActivityPub(asyncMiddleware(videoController)) 38 executeIfActivityPub(asyncMiddleware(videoController))
38) 39)
40activityPubClientRouter.get('/videos/watch/:id/activity',
41 executeIfActivityPub(asyncMiddleware(videosGetValidator)),
42 executeIfActivityPub(asyncMiddleware(videoController))
43)
39activityPubClientRouter.get('/videos/watch/:id/announces', 44activityPubClientRouter.get('/videos/watch/:id/announces',
40 executeIfActivityPub(asyncMiddleware(videosGetValidator)), 45 executeIfActivityPub(asyncMiddleware(videosGetValidator)),
41 executeIfActivityPub(asyncMiddleware(videoAnnouncesController)) 46 executeIfActivityPub(asyncMiddleware(videoAnnouncesController))
@@ -60,6 +65,10 @@ activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId',
60 executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)), 65 executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)),
61 executeIfActivityPub(asyncMiddleware(videoCommentController)) 66 executeIfActivityPub(asyncMiddleware(videoCommentController))
62) 67)
68activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity',
69 executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)),
70 executeIfActivityPub(asyncMiddleware(videoCommentController))
71)
63 72
64activityPubClientRouter.get('/video-channels/:id', 73activityPubClientRouter.get('/video-channels/:id',
65 executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)), 74 executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)),
@@ -111,6 +120,11 @@ async function videoController (req: express.Request, res: express.Response, nex
111 const audience = await getAudience(video.VideoChannel.Account.Actor, undefined, video.privacy === VideoPrivacy.PUBLIC) 120 const audience = await getAudience(video.VideoChannel.Account.Actor, undefined, video.privacy === VideoPrivacy.PUBLIC)
112 const videoObject = audiencify(videoAll.toActivityPubObject(), audience) 121 const videoObject = audiencify(videoAll.toActivityPubObject(), audience)
113 122
123 if (req.path.endsWith('/activity')) {
124 const data = await createActivityData(video.url, video.VideoChannel.Account.Actor, videoObject, undefined, audience)
125 return res.json(activityPubContextify(data))
126 }
127
114 return res.json(activityPubContextify(videoObject)) 128 return res.json(activityPubContextify(videoObject))
115} 129}
116 130
@@ -190,6 +204,11 @@ async function videoCommentController (req: express.Request, res: express.Respon
190 204
191 const videoCommentObject = audiencify(videoComment.toActivityPubObject(threadParentComments), audience) 205 const videoCommentObject = audiencify(videoComment.toActivityPubObject(threadParentComments), audience)
192 206
207 if (req.path.endsWith('/activity')) {
208 const data = await createActivityData(videoComment.url, videoComment.Account.Actor, videoCommentObject, undefined, audience)
209 return res.json(activityPubContextify(data))
210 }
211
193 return res.json(activityPubContextify(videoCommentObject)) 212 return res.json(activityPubContextify(videoCommentObject))
194} 213}
195 214