Add activity route to video and video comment objects
This commit is contained in:
parent
bebf2d89d3
commit
296c090563
1 changed files with 19 additions and 0 deletions
|
@ -6,6 +6,7 @@ import { pageToStartAndCount } from '../../helpers/core-utils'
|
||||||
import { ACTIVITY_PUB, CONFIG } from '../../initializers'
|
import { ACTIVITY_PUB, CONFIG } from '../../initializers'
|
||||||
import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send'
|
import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send'
|
||||||
import { audiencify, getAudience } from '../../lib/activitypub/send/misc'
|
import { audiencify, getAudience } from '../../lib/activitypub/send/misc'
|
||||||
|
import { createActivityData } from '../../lib/activitypub/send/send-create'
|
||||||
import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares'
|
import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares'
|
||||||
import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators'
|
import { videoChannelsGetValidator, videosGetValidator, videosShareValidator } from '../../middlewares/validators'
|
||||||
import { videoCommentGetValidator } from '../../middlewares/validators/video-comments'
|
import { videoCommentGetValidator } from '../../middlewares/validators/video-comments'
|
||||||
|
@ -36,6 +37,10 @@ activityPubClientRouter.get('/videos/watch/:id',
|
||||||
executeIfActivityPub(asyncMiddleware(videosGetValidator)),
|
executeIfActivityPub(asyncMiddleware(videosGetValidator)),
|
||||||
executeIfActivityPub(asyncMiddleware(videoController))
|
executeIfActivityPub(asyncMiddleware(videoController))
|
||||||
)
|
)
|
||||||
|
activityPubClientRouter.get('/videos/watch/:id/activity',
|
||||||
|
executeIfActivityPub(asyncMiddleware(videosGetValidator)),
|
||||||
|
executeIfActivityPub(asyncMiddleware(videoController))
|
||||||
|
)
|
||||||
activityPubClientRouter.get('/videos/watch/:id/announces',
|
activityPubClientRouter.get('/videos/watch/:id/announces',
|
||||||
executeIfActivityPub(asyncMiddleware(videosGetValidator)),
|
executeIfActivityPub(asyncMiddleware(videosGetValidator)),
|
||||||
executeIfActivityPub(asyncMiddleware(videoAnnouncesController))
|
executeIfActivityPub(asyncMiddleware(videoAnnouncesController))
|
||||||
|
@ -60,6 +65,10 @@ activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId',
|
||||||
executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)),
|
executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)),
|
||||||
executeIfActivityPub(asyncMiddleware(videoCommentController))
|
executeIfActivityPub(asyncMiddleware(videoCommentController))
|
||||||
)
|
)
|
||||||
|
activityPubClientRouter.get('/videos/watch/:videoId/comments/:commentId/activity',
|
||||||
|
executeIfActivityPub(asyncMiddleware(videoCommentGetValidator)),
|
||||||
|
executeIfActivityPub(asyncMiddleware(videoCommentController))
|
||||||
|
)
|
||||||
|
|
||||||
activityPubClientRouter.get('/video-channels/:id',
|
activityPubClientRouter.get('/video-channels/:id',
|
||||||
executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)),
|
executeIfActivityPub(asyncMiddleware(videoChannelsGetValidator)),
|
||||||
|
@ -111,6 +120,11 @@ async function videoController (req: express.Request, res: express.Response, nex
|
||||||
const audience = await getAudience(video.VideoChannel.Account.Actor, undefined, video.privacy === VideoPrivacy.PUBLIC)
|
const audience = await getAudience(video.VideoChannel.Account.Actor, undefined, video.privacy === VideoPrivacy.PUBLIC)
|
||||||
const videoObject = audiencify(videoAll.toActivityPubObject(), audience)
|
const videoObject = audiencify(videoAll.toActivityPubObject(), audience)
|
||||||
|
|
||||||
|
if (req.path.endsWith('/activity')) {
|
||||||
|
const data = await createActivityData(video.url, video.VideoChannel.Account.Actor, videoObject, undefined, audience)
|
||||||
|
return res.json(activityPubContextify(data))
|
||||||
|
}
|
||||||
|
|
||||||
return res.json(activityPubContextify(videoObject))
|
return res.json(activityPubContextify(videoObject))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +204,11 @@ async function videoCommentController (req: express.Request, res: express.Respon
|
||||||
|
|
||||||
const videoCommentObject = audiencify(videoComment.toActivityPubObject(threadParentComments), audience)
|
const videoCommentObject = audiencify(videoComment.toActivityPubObject(threadParentComments), audience)
|
||||||
|
|
||||||
|
if (req.path.endsWith('/activity')) {
|
||||||
|
const data = await createActivityData(videoComment.url, videoComment.Account.Actor, videoCommentObject, undefined, audience)
|
||||||
|
return res.json(activityPubContextify(data))
|
||||||
|
}
|
||||||
|
|
||||||
return res.json(activityPubContextify(videoCommentObject))
|
return res.json(activityPubContextify(videoCommentObject))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue