1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Server shares user videos

This commit is contained in:
Chocobozzz 2017-11-16 15:22:39 +01:00
parent efc32059d9
commit 20494f1221
No known key found for this signature in database
GPG key ID: 583A612D890159BE
16 changed files with 215 additions and 111 deletions

View file

@ -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())
}