aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-05-03 11:38:07 +0200
committerChocobozzz <me@florianbigard.com>2022-05-03 14:49:15 +0200
commit26e3e98ff0e222a9fb9226938ac6902af77921bd (patch)
tree73d1c6f2524e380862d3365f12043fc319d40841 /server/middlewares/validators
parent86c5229b4d726202378ef46854383bcafca22310 (diff)
downloadPeerTube-26e3e98ff0e222a9fb9226938ac6902af77921bd.tar.gz
PeerTube-26e3e98ff0e222a9fb9226938ac6902af77921bd.tar.zst
PeerTube-26e3e98ff0e222a9fb9226938ac6902af77921bd.zip
Support live session in server
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r--server/middlewares/validators/videos/video-live.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts
index ff492da0f..59638d5e0 100644
--- a/server/middlewares/validators/videos/video-live.ts
+++ b/server/middlewares/validators/videos/video-live.ts
@@ -28,6 +28,7 @@ import {
28 isValidVideoIdParam 28 isValidVideoIdParam
29} from '../shared' 29} from '../shared'
30import { getCommonVideoEditAttributes } from './videos' 30import { getCommonVideoEditAttributes } from './videos'
31import { VideoLiveSessionModel } from '@server/models/video/video-live-session'
31 32
32const videoLiveGetValidator = [ 33const videoLiveGetValidator = [
33 isValidVideoIdParam('videoId'), 34 isValidVideoIdParam('videoId'),
@@ -196,11 +197,48 @@ const videoLiveUpdateValidator = [
196 } 197 }
197] 198]
198 199
200const videoLiveListSessionsValidator = [
201 (req: express.Request, res: express.Response, next: express.NextFunction) => {
202 logger.debug('Checking videoLiveListSessionsValidator parameters', { parameters: req.params })
203
204 // Check the user can manage the live
205 const user = res.locals.oauth.token.User
206 if (!checkUserCanManageVideo(user, res.locals.videoAll, UserRight.GET_ANY_LIVE, res)) return
207
208 return next()
209 }
210]
211
212const videoLiveFindReplaySessionValidator = [
213 isValidVideoIdParam('videoId'),
214
215 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
216 logger.debug('Checking videoLiveFindReplaySessionValidator parameters', { parameters: req.params })
217
218 if (areValidationErrors(req, res)) return
219 if (!await doesVideoExist(req.params.videoId, res, 'id')) return
220
221 const session = await VideoLiveSessionModel.findSessionOfReplay(res.locals.videoId.id)
222 if (!session) {
223 return res.fail({
224 status: HttpStatusCode.NOT_FOUND_404,
225 message: 'No live replay found'
226 })
227 }
228
229 res.locals.videoLiveSession = session
230
231 return next()
232 }
233]
234
199// --------------------------------------------------------------------------- 235// ---------------------------------------------------------------------------
200 236
201export { 237export {
202 videoLiveAddValidator, 238 videoLiveAddValidator,
203 videoLiveUpdateValidator, 239 videoLiveUpdateValidator,
240 videoLiveListSessionsValidator,
241 videoLiveFindReplaySessionValidator,
204 videoLiveGetValidator 242 videoLiveGetValidator
205} 243}
206 244