diff options
Diffstat (limited to 'server/controllers/activitypub')
-rw-r--r-- | server/controllers/activitypub/client.ts | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 76049f496..7b3921770 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -4,10 +4,13 @@ import * as express from 'express' | |||
4 | import { database as db } from '../../initializers' | 4 | import { database as db } from '../../initializers' |
5 | import { executeIfActivityPub, localAccountValidator } from '../../middlewares' | 5 | import { executeIfActivityPub, localAccountValidator } from '../../middlewares' |
6 | import { pageToStartAndCount } from '../../helpers' | 6 | import { pageToStartAndCount } from '../../helpers' |
7 | import { AccountInstance } from '../../models' | 7 | import { AccountInstance, VideoChannelInstance } from '../../models' |
8 | import { activityPubCollectionPagination } from '../../helpers/activitypub' | 8 | import { activityPubCollectionPagination } from '../../helpers/activitypub' |
9 | import { ACTIVITY_PUB } from '../../initializers/constants' | 9 | import { ACTIVITY_PUB } from '../../initializers/constants' |
10 | import { asyncMiddleware } from '../../middlewares/async' | 10 | import { asyncMiddleware } from '../../middlewares/async' |
11 | import { videosGetValidator } from '../../middlewares/validators/videos' | ||
12 | import { VideoInstance } from '../../models/video/video-interface' | ||
13 | import { videoChannelsGetValidator } from '../../middlewares/validators/video-channels' | ||
11 | 14 | ||
12 | const activityPubClientRouter = express.Router() | 15 | const activityPubClientRouter = express.Router() |
13 | 16 | ||
@@ -26,6 +29,16 @@ activityPubClientRouter.get('/account/:name/following', | |||
26 | executeIfActivityPub(asyncMiddleware(accountFollowingController)) | 29 | executeIfActivityPub(asyncMiddleware(accountFollowingController)) |
27 | ) | 30 | ) |
28 | 31 | ||
32 | activityPubClientRouter.get('/videos/watch/:id', | ||
33 | executeIfActivityPub(videosGetValidator), | ||
34 | executeIfActivityPub(asyncMiddleware(videoController)) | ||
35 | ) | ||
36 | |||
37 | activityPubClientRouter.get('/video-channels/:id', | ||
38 | executeIfActivityPub(videoChannelsGetValidator), | ||
39 | executeIfActivityPub(asyncMiddleware(videoChannelController)) | ||
40 | ) | ||
41 | |||
29 | // --------------------------------------------------------------------------- | 42 | // --------------------------------------------------------------------------- |
30 | 43 | ||
31 | export { | 44 | export { |
@@ -63,3 +76,15 @@ async function accountFollowingController (req: express.Request, res: express.Re | |||
63 | 76 | ||
64 | return res.json(activityPubResult) | 77 | return res.json(activityPubResult) |
65 | } | 78 | } |
79 | |||
80 | async function videoController (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
81 | const video: VideoInstance = res.locals.video | ||
82 | |||
83 | return res.json(video.toActivityPubObject()) | ||
84 | } | ||
85 | |||
86 | async function videoChannelController (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
87 | const videoChannel: VideoChannelInstance = res.locals.videoChannel | ||
88 | |||
89 | return res.json(videoChannel.toActivityPubObject()) | ||
90 | } | ||