diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-16 15:22:39 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 20494f122186bb1bfd82f4c598c4744acea27b0c (patch) | |
tree | 097652a31ecf70491b970b6c8e06b22380ee004f /server/controllers/activitypub | |
parent | efc32059d980c51793e8e9ac0fb6a885a8026f94 (diff) | |
download | PeerTube-20494f122186bb1bfd82f4c598c4744acea27b0c.tar.gz PeerTube-20494f122186bb1bfd82f4c598c4744acea27b0c.tar.zst PeerTube-20494f122186bb1bfd82f4c598c4744acea27b0c.zip |
Server shares user videos
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 | } | ||