+ const videoChannel: VideoChannelModel = res.locals.videoChannel
+
+ return activityPubResponse(activityPubContextify(videoChannel.toActivityPubObject()), res)
+}
+
+async function videoChannelFollowersController (req: express.Request, res: express.Response, next: express.NextFunction) {
+ const videoChannel: VideoChannelModel = res.locals.videoChannel
+ const activityPubResult = await actorFollowers(req, videoChannel.Actor)
+
+ return activityPubResponse(activityPubContextify(activityPubResult), res)
+}
+
+async function videoChannelFollowingController (req: express.Request, res: express.Response, next: express.NextFunction) {
+ const videoChannel: VideoChannelModel = res.locals.videoChannel
+ const activityPubResult = await actorFollowing(req, videoChannel.Actor)
+
+ return activityPubResponse(activityPubContextify(activityPubResult), res)
+}
+
+async function videoCommentController (req: express.Request, res: express.Response, next: express.NextFunction) {
+ const videoComment: VideoCommentModel = res.locals.videoComment
+
+ const threadParentComments = await VideoCommentModel.listThreadParentComments(videoComment, undefined)
+ const isPublic = true // Comments are always public
+ const audience = getAudience(videoComment.Account.Actor, isPublic)
+
+ const videoCommentObject = audiencify(videoComment.toActivityPubObject(threadParentComments), audience)
+
+ if (req.path.endsWith('/activity')) {
+ const data = createActivityData(videoComment.url, videoComment.Account.Actor, videoCommentObject, audience)
+ return activityPubResponse(activityPubContextify(data), res)
+ }
+
+ return activityPubResponse(activityPubContextify(videoCommentObject), res)
+}
+
+// ---------------------------------------------------------------------------
+
+async function actorFollowing (req: express.Request, actor: ActorModel) {
+ const handler = (start: number, count: number) => {
+ return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count)
+ }
+
+ return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, handler, req.query.page)
+}
+
+async function actorFollowers (req: express.Request, actor: ActorModel) {
+ const handler = (start: number, count: number) => {
+ return ActorFollowModel.listAcceptedFollowerUrlsForApi([ actor.id ], undefined, start, count)
+ }
+
+ return activityPubCollectionPagination(CONFIG.WEBSERVER.URL + req.url, handler, req.query.page)
+}