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:
parent
efc32059d9
commit
20494f1221
16 changed files with 215 additions and 111 deletions
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue