From 46531a0abdd5c860a1a8cdb4b636b9c55bfb115b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 29 Jan 2018 10:52:19 +0100 Subject: Add id to likes/dislikes/comments/shares collections --- server/controllers/activitypub/client.ts | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'server/controllers/activitypub') 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', executeIfActivityPub(asyncMiddleware(videosGetValidator)), executeIfActivityPub(asyncMiddleware(videoController)) ) +activityPubClientRouter.get('/videos/watch/:id/announces', + executeIfActivityPub(asyncMiddleware(videosGetValidator)), + executeIfActivityPub(asyncMiddleware(videoAnnouncesController)) +) activityPubClientRouter.get('/videos/watch/:id/announces/:accountId', executeIfActivityPub(asyncMiddleware(videosShareValidator)), executeIfActivityPub(asyncMiddleware(videoAnnounceController)) ) +activityPubClientRouter.get('/videos/watch/:id/likes', + executeIfActivityPub(asyncMiddleware(videosGetValidator)), + executeIfActivityPub(asyncMiddleware(videoLikesController)) +) +activityPubClientRouter.get('/videos/watch/:id/dislikes', + executeIfActivityPub(asyncMiddleware(videosGetValidator)), + executeIfActivityPub(asyncMiddleware(videoDislikesController)) +) +activityPubClientRouter.get('/videos/watch/:id/comments', + executeIfActivityPub(asyncMiddleware(videosGetValidator)), + executeIfActivityPub(asyncMiddleware(videoCommentsController)) +) activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId', executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)), executeIfActivityPub(asyncMiddleware(videoCommentController)) @@ -105,6 +121,46 @@ async function videoAnnounceController (req: express.Request, res: express.Respo return res.json(activityPubContextify(object)) } +async function videoAnnouncesController (req: express.Request, res: express.Response, next: express.NextFunction) { + const video: VideoModel = res.locals.video + + // We need more attributes + const videoAll = await VideoModel.loadAndPopulateAll(video.id) + const object = videoAll.toAnnouncesActivityPubObject() + + return res.json(activityPubContextify(object)) +} + +async function videoLikesController (req: express.Request, res: express.Response, next: express.NextFunction) { + const video: VideoModel = res.locals.video + + // We need more attributes + const videoAll = await VideoModel.loadAndPopulateAll(video.id) + const { likesObject } = videoAll.toRatesActivityPubObjects() + + return res.json(activityPubContextify(likesObject)) +} + +async function videoDislikesController (req: express.Request, res: express.Response, next: express.NextFunction) { + const video: VideoModel = res.locals.video + + // We need more attributes + const videoAll = await VideoModel.loadAndPopulateAll(video.id) + const { dislikesObject } = videoAll.toRatesActivityPubObjects() + + return res.json(activityPubContextify(dislikesObject)) +} + +async function videoCommentsController (req: express.Request, res: express.Response, next: express.NextFunction) { + const video: VideoModel = res.locals.video + + // We need more attributes + const videoAll = await VideoModel.loadAndPopulateAll(video.id) + const commentsObject = videoAll.toCommentsActivityPubObject() + + return res.json(activityPubContextify(commentsObject)) +} + async function videoChannelController (req: express.Request, res: express.Response, next: express.NextFunction) { const videoChannel: VideoChannelModel = res.locals.videoChannel -- cgit v1.2.3