diff options
Diffstat (limited to 'server/middlewares/validators/redundancy.ts')
-rw-r--r-- | server/middlewares/validators/redundancy.ts | 18 |
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 | ||
43 | const videoPlaylistRedundancyGetValidator = [ | 47 | const 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 |