diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-22 17:08:02 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-03-22 17:12:25 +0100 |
commit | 296c090563f9d609d3c55dec378a3a1d65c4bd78 (patch) | |
tree | 241ed8a3b49ef536abb06152a2bcfdeb6408fc42 /server | |
parent | bebf2d89d335c48659d2e25cb9f6f8310e867fc5 (diff) | |
download | PeerTube-296c090563f9d609d3c55dec378a3a1d65c4bd78.tar.gz PeerTube-296c090563f9d609d3c55dec378a3a1d65c4bd78.tar.zst PeerTube-296c090563f9d609d3c55dec378a3a1d65c4bd78.zip |
Add activity route to video and video comment objects
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/activitypub/client.ts | 19 |
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' | |||
6 | import { ACTIVITY_PUB, CONFIG } from '../../initializers' | 6 | import { ACTIVITY_PUB, CONFIG } from '../../initializers' |
7 | import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' | 7 | import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' |
8 | import { audiencify, getAudience } from '../../lib/activitypub/send/misc' | 8 | import { audiencify, getAudience } from '../../lib/activitypub/send/misc' |
9 | import { createActivityData } from '../../lib/activitypub/send/send-create' | ||
9 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' | 10 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' |
10 | import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators' | 11 | import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators' |
11 | import { videoCommentGetValidator } from '../../middlewares/validators/video-comments' | 12 | import { 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 | ) |
40 | activityPubClientRouter.get('/videos/watch/:id/activity', | ||
41 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), | ||
42 | executeIfActivityPub(asyncMiddleware(videoController)) | ||
43 | ) | ||
39 | activityPubClientRouter.get('/videos/watch/:id/announces', | 44 | activityPubClientRouter.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 | ) |
68 | activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity', | ||
69 | executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)), | ||
70 | executeIfActivityPub(asyncMiddleware(videoCommentController)) | ||
71 | ) | ||
63 | 72 | ||
64 | activityPubClientRouter.get('/video-channels/:id', | 73 | activityPubClientRouter.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 | ||