diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-29 10:52:19 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-29 10:52:19 +0100 |
commit | 46531a0abdd5c860a1a8cdb4b636b9c55bfb115b (patch) | |
tree | 9cc1aaa565985c04b12bf985e9c6f21aebf42ff3 /server/controllers | |
parent | c88593f72f1097cc34a091b4cb4b6d6e214d1e9f (diff) | |
download | PeerTube-46531a0abdd5c860a1a8cdb4b636b9c55bfb115b.tar.gz PeerTube-46531a0abdd5c860a1a8cdb4b636b9c55bfb115b.tar.zst PeerTube-46531a0abdd5c860a1a8cdb4b636b9c55bfb115b.zip |
Add id to likes/dislikes/comments/shares collections
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 7b60cc311..55bd85c48 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -36,10 +36,26 @@ activityPubClientRouter.get('/videos/watch/:id', | |||
36 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), | 36 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), |
37 | executeIfActivityPub(asyncMiddleware(videoController)) | 37 | executeIfActivityPub(asyncMiddleware(videoController)) |
38 | ) | 38 | ) |
39 | activityPubClientRouter.get('/videos/watch/:id/announces', | ||
40 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), | ||
41 | executeIfActivityPub(asyncMiddleware(videoAnnouncesController)) | ||
42 | ) | ||
39 | activityPubClientRouter.get('/videos/watch/:id/announces/:accountId', | 43 | activityPubClientRouter.get('/videos/watch/:id/announces/:accountId', |
40 | executeIfActivityPub(asyncMiddleware(videosShareValidator)), | 44 | executeIfActivityPub(asyncMiddleware(videosShareValidator)), |
41 | executeIfActivityPub(asyncMiddleware(videoAnnounceController)) | 45 | executeIfActivityPub(asyncMiddleware(videoAnnounceController)) |
42 | ) | 46 | ) |
47 | activityPubClientRouter.get('/videos/watch/:id/likes', | ||
48 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), | ||
49 | executeIfActivityPub(asyncMiddleware(videoLikesController)) | ||
50 | ) | ||
51 | activityPubClientRouter.get('/videos/watch/:id/dislikes', | ||
52 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), | ||
53 | executeIfActivityPub(asyncMiddleware(videoDislikesController)) | ||
54 | ) | ||
55 | activityPubClientRouter.get('/videos/watch/:id/comments', | ||
56 | executeIfActivityPub(asyncMiddleware(videosGetValidator)), | ||
57 | executeIfActivityPub(asyncMiddleware(videoCommentsController)) | ||
58 | ) | ||
43 | activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId', | 59 | activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId', |
44 | executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)), | 60 | executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)), |
45 | executeIfActivityPub(asyncMiddleware(videoCommentController)) | 61 | executeIfActivityPub(asyncMiddleware(videoCommentController)) |
@@ -105,6 +121,46 @@ async function videoAnnounceController (req: express.Request, res: express.Respo | |||
105 | return res.json(activityPubContextify(object)) | 121 | return res.json(activityPubContextify(object)) |
106 | } | 122 | } |
107 | 123 | ||
124 | async function videoAnnouncesController (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
125 | const video: VideoModel = res.locals.video | ||
126 | |||
127 | // We need more attributes | ||
128 | const videoAll = await VideoModel.loadAndPopulateAll(video.id) | ||
129 | const object = videoAll.toAnnouncesActivityPubObject() | ||
130 | |||
131 | return res.json(activityPubContextify(object)) | ||
132 | } | ||
133 | |||
134 | async function videoLikesController (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
135 | const video: VideoModel = res.locals.video | ||
136 | |||
137 | // We need more attributes | ||
138 | const videoAll = await VideoModel.loadAndPopulateAll(video.id) | ||
139 | const { likesObject } = videoAll.toRatesActivityPubObjects() | ||
140 | |||
141 | return res.json(activityPubContextify(likesObject)) | ||
142 | } | ||
143 | |||
144 | async function videoDislikesController (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
145 | const video: VideoModel = res.locals.video | ||
146 | |||
147 | // We need more attributes | ||
148 | const videoAll = await VideoModel.loadAndPopulateAll(video.id) | ||
149 | const { dislikesObject } = videoAll.toRatesActivityPubObjects() | ||
150 | |||
151 | return res.json(activityPubContextify(dislikesObject)) | ||
152 | } | ||
153 | |||
154 | async function videoCommentsController (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
155 | const video: VideoModel = res.locals.video | ||
156 | |||
157 | // We need more attributes | ||
158 | const videoAll = await VideoModel.loadAndPopulateAll(video.id) | ||
159 | const commentsObject = videoAll.toCommentsActivityPubObject() | ||
160 | |||
161 | return res.json(activityPubContextify(commentsObject)) | ||
162 | } | ||
163 | |||
108 | async function videoChannelController (req: express.Request, res: express.Response, next: express.NextFunction) { | 164 | async function videoChannelController (req: express.Request, res: express.Response, next: express.NextFunction) { |
109 | const videoChannel: VideoChannelModel = res.locals.videoChannel | 165 | const videoChannel: VideoChannelModel = res.locals.videoChannel |
110 | 166 | ||