+function accountController (req: express.Request, res: express.Response) {
+ const account = res.locals.account
+
+ return activityPubResponse(activityPubContextify(account.toActivityPubObject()), res)
+}
+
+async function accountFollowersController (req: express.Request, res: express.Response) {
+ const account = res.locals.account
+ const activityPubResult = await actorFollowers(req, account.Actor)
+
+ return activityPubResponse(activityPubContextify(activityPubResult), res)
+}
+
+async function accountFollowingController (req: express.Request, res: express.Response) {
+ const account = res.locals.account
+ const activityPubResult = await actorFollowing(req, account.Actor)
+
+ return activityPubResponse(activityPubContextify(activityPubResult), res)
+}
+
+async function accountPlaylistsController (req: express.Request, res: express.Response) {
+ const account = res.locals.account
+ const activityPubResult = await actorPlaylists(req, account)
+
+ return activityPubResponse(activityPubContextify(activityPubResult), res)
+}
+
+function getAccountVideoRate (rateType: VideoRateType) {
+ return (req: express.Request, res: express.Response) => {
+ const accountVideoRate = res.locals.accountVideoRate
+
+ const byActor = accountVideoRate.Account.Actor
+ const url = getRateUrl(rateType, byActor, accountVideoRate.Video)
+ const APObject = rateType === 'like'
+ ? buildLikeActivity(url, byActor, accountVideoRate.Video)
+ : buildDislikeActivity(url, byActor, accountVideoRate.Video)
+
+ return activityPubResponse(activityPubContextify(APObject), res)
+ }
+}
+
+async function videoController (req: express.Request, res: express.Response) {
+ // We need more attributes
+ const video = await VideoModel.loadForGetAPI({ id: res.locals.onlyVideoWithRights.id }) as MVideoAPWithoutCaption
+
+ if (video.url.startsWith(WEBSERVER.URL) === false) return res.redirect(video.url)
+
+ // We need captions to render AP object
+ const captions = await VideoCaptionModel.listVideoCaptions(video.id)
+ const videoWithCaptions = Object.assign(video, { VideoCaptions: captions })
+
+ const audience = getAudience(videoWithCaptions.VideoChannel.Account.Actor, videoWithCaptions.privacy === VideoPrivacy.PUBLIC)
+ const videoObject = audiencify(videoWithCaptions.toActivityPubObject(), audience)
+
+ if (req.path.endsWith('/activity')) {
+ const data = buildCreateActivity(videoWithCaptions.url, video.VideoChannel.Account.Actor, videoObject, audience)
+ return activityPubResponse(activityPubContextify(data), res)
+ }