From 20494f122186bb1bfd82f4c598c4744acea27b0c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Nov 2017 15:22:39 +0100 Subject: Server shares user videos --- server/controllers/activitypub/client.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'server/controllers/activitypub/client.ts') 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' import { database as db } from '../../initializers' import { executeIfActivityPub, localAccountValidator } from '../../middlewares' import { pageToStartAndCount } from '../../helpers' -import { AccountInstance } from '../../models' +import { AccountInstance, VideoChannelInstance } from '../../models' import { activityPubCollectionPagination } from '../../helpers/activitypub' import { ACTIVITY_PUB } from '../../initializers/constants' import { asyncMiddleware } from '../../middlewares/async' +import { videosGetValidator } from '../../middlewares/validators/videos' +import { VideoInstance } from '../../models/video/video-interface' +import { videoChannelsGetValidator } from '../../middlewares/validators/video-channels' const activityPubClientRouter = express.Router() @@ -26,6 +29,16 @@ activityPubClientRouter.get('/account/:name/following', executeIfActivityPub(asyncMiddleware(accountFollowingController)) ) +activityPubClientRouter.get('/videos/watch/:id', + executeIfActivityPub(videosGetValidator), + executeIfActivityPub(asyncMiddleware(videoController)) +) + +activityPubClientRouter.get('/video-channels/:id', + executeIfActivityPub(videoChannelsGetValidator), + executeIfActivityPub(asyncMiddleware(videoChannelController)) +) + // --------------------------------------------------------------------------- export { @@ -63,3 +76,15 @@ async function accountFollowingController (req: express.Request, res: express.Re return res.json(activityPubResult) } + +async function videoController (req: express.Request, res: express.Response, next: express.NextFunction) { + const video: VideoInstance = res.locals.video + + return res.json(video.toActivityPubObject()) +} + +async function videoChannelController (req: express.Request, res: express.Response, next: express.NextFunction) { + const videoChannel: VideoChannelInstance = res.locals.videoChannel + + return res.json(videoChannel.toActivityPubObject()) +} -- cgit v1.2.3