diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 27 | ||||
-rw-r--r-- | server/controllers/api/videos/channel.ts | 4 |
2 files changed, 28 insertions, 3 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 | } | ||
diff --git a/server/controllers/api/videos/channel.ts b/server/controllers/api/videos/channel.ts index 656bc3129..8f3df2550 100644 --- a/server/controllers/api/videos/channel.ts +++ b/server/controllers/api/videos/channel.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | paginationValidator, | 10 | paginationValidator, |
11 | setPagination, | 11 | setPagination, |
12 | setVideoChannelsSort, | 12 | setVideoChannelsSort, |
13 | videoChannelGetValidator, | 13 | videoChannelsGetValidator, |
14 | videoChannelsAddValidator, | 14 | videoChannelsAddValidator, |
15 | videoChannelsRemoveValidator, | 15 | videoChannelsRemoveValidator, |
16 | videoChannelsSortValidator, | 16 | videoChannelsSortValidator, |
@@ -53,7 +53,7 @@ videoChannelRouter.delete('/channels/:id', | |||
53 | ) | 53 | ) |
54 | 54 | ||
55 | videoChannelRouter.get('/channels/:id', | 55 | videoChannelRouter.get('/channels/:id', |
56 | videoChannelGetValidator, | 56 | videoChannelsGetValidator, |
57 | asyncMiddleware(getVideoChannel) | 57 | asyncMiddleware(getVideoChannel) |
58 | ) | 58 | ) |
59 | 59 | ||