aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/redundancy.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-10-21 14:50:55 +0200
committerChocobozzz <me@florianbigard.com>2019-10-21 15:03:28 +0200
commitd5d9b6d7bfb7e9426b6462f7fdf285df39eea820 (patch)
treeaa21a16be3df94b5c6fd264d1090ed9ac7c94a79 /server/middlewares/validators/redundancy.ts
parentf6e0de3f48993b2c0ef9bd2c24d2d7443acc6ace (diff)
downloadPeerTube-d5d9b6d7bfb7e9426b6462f7fdf285df39eea820.tar.gz
PeerTube-d5d9b6d7bfb7e9426b6462f7fdf285df39eea820.tar.zst
PeerTube-d5d9b6d7bfb7e9426b6462f7fdf285df39eea820.zip
Update server dependencies
Diffstat (limited to 'server/middlewares/validators/redundancy.ts')
-rw-r--r--server/middlewares/validators/redundancy.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts
index e65d3b8d3..8098e3a44 100644
--- a/server/middlewares/validators/redundancy.ts
+++ b/server/middlewares/validators/redundancy.ts
@@ -25,8 +25,12 @@ const videoFileRedundancyGetValidator = [
25 if (!await doesVideoExist(req.params.videoId, res)) return 25 if (!await doesVideoExist(req.params.videoId, res)) return
26 26
27 const video = res.locals.videoAll 27 const video = res.locals.videoAll
28
29 const paramResolution = req.params.resolution as unknown as number // We casted to int above
30 const paramFPS = req.params.fps as unknown as number // We casted to int above
31
28 const videoFile = video.VideoFiles.find(f => { 32 const videoFile = video.VideoFiles.find(f => {
29 return f.resolution === req.params.resolution && (!req.params.fps || f.fps === req.params.fps) 33 return f.resolution === paramResolution && (!req.params.fps || paramFPS)
30 }) 34 })
31 35
32 if (!videoFile) return res.status(404).json({ error: 'Video file not found.' }) 36 if (!videoFile) return res.status(404).json({ error: 'Video file not found.' })
@@ -41,8 +45,12 @@ const videoFileRedundancyGetValidator = [
41] 45]
42 46
43const videoPlaylistRedundancyGetValidator = [ 47const videoPlaylistRedundancyGetValidator = [
44 param('videoId').custom(isIdOrUUIDValid).not().isEmpty().withMessage('Should have a valid video id'), 48 param('videoId')
45 param('streamingPlaylistType').custom(exists).withMessage('Should have a valid streaming playlist type'), 49 .custom(isIdOrUUIDValid)
50 .not().isEmpty().withMessage('Should have a valid video id'),
51 param('streamingPlaylistType')
52 .customSanitizer(toIntOrNull)
53 .custom(exists).withMessage('Should have a valid streaming playlist type'),
46 54
47 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 55 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
48 logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params }) 56 logger.debug('Checking videoPlaylistRedundancyGetValidator parameters', { parameters: req.params })
@@ -51,7 +59,9 @@ const videoPlaylistRedundancyGetValidator = [
51 if (!await doesVideoExist(req.params.videoId, res)) return 59 if (!await doesVideoExist(req.params.videoId, res)) return
52 60
53 const video = res.locals.videoAll 61 const video = res.locals.videoAll
54 const videoStreamingPlaylist = video.VideoStreamingPlaylists.find(p => p === req.params.streamingPlaylistType) 62
63 const paramPlaylistType = req.params.streamingPlaylistType as unknown as number // We casted to int above
64 const videoStreamingPlaylist = video.VideoStreamingPlaylists.find(p => p.type === paramPlaylistType)
55 65
56 if (!videoStreamingPlaylist) return res.status(404).json({ error: 'Video playlist not found.' }) 66 if (!videoStreamingPlaylist) return res.status(404).json({ error: 'Video playlist not found.' })
57 res.locals.videoStreamingPlaylist = videoStreamingPlaylist 67 res.locals.videoStreamingPlaylist = videoStreamingPlaylist