diff options
author | Chocobozzz <me@florianbigard.com> | 2019-10-21 14:50:55 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-10-21 15:03:28 +0200 |
commit | d5d9b6d7bfb7e9426b6462f7fdf285df39eea820 (patch) | |
tree | aa21a16be3df94b5c6fd264d1090ed9ac7c94a79 /server/middlewares | |
parent | f6e0de3f48993b2c0ef9bd2c24d2d7443acc6ace (diff) | |
download | PeerTube-d5d9b6d7bfb7e9426b6462f7fdf285df39eea820.tar.gz PeerTube-d5d9b6d7bfb7e9426b6462f7fdf285df39eea820.tar.zst PeerTube-d5d9b6d7bfb7e9426b6462f7fdf285df39eea820.zip |
Update server dependencies
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/redundancy.ts | 18 | ||||
-rw-r--r-- | server/middlewares/validators/users.ts | 3 | ||||
-rw-r--r-- | server/middlewares/validators/videos/video-comments.ts | 6 |
3 files changed, 20 insertions, 7 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 |
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index b3466333c..804d1410e 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -448,7 +448,8 @@ export { | |||
448 | 448 | ||
449 | // --------------------------------------------------------------------------- | 449 | // --------------------------------------------------------------------------- |
450 | 450 | ||
451 | function checkUserIdExist (id: number, res: express.Response) { | 451 | function checkUserIdExist (idArg: number | string, res: express.Response) { |
452 | const id = parseInt(idArg + '', 10) | ||
452 | return checkUserExist(() => UserModel.loadById(id), res) | 453 | return checkUserExist(() => UserModel.loadById(id), res) |
453 | } | 454 | } |
454 | 455 | ||
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts index 8adbb02ba..1d81eb5d8 100644 --- a/server/middlewares/validators/videos/video-comments.ts +++ b/server/middlewares/validators/videos/video-comments.ts | |||
@@ -120,7 +120,8 @@ export { | |||
120 | 120 | ||
121 | // --------------------------------------------------------------------------- | 121 | // --------------------------------------------------------------------------- |
122 | 122 | ||
123 | async function doesVideoCommentThreadExist (id: number, video: MVideoId, res: express.Response) { | 123 | async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) { |
124 | const id = parseInt(idArg + '', 10) | ||
124 | const videoComment = await VideoCommentModel.loadById(id) | 125 | const videoComment = await VideoCommentModel.loadById(id) |
125 | 126 | ||
126 | if (!videoComment) { | 127 | if (!videoComment) { |
@@ -151,7 +152,8 @@ async function doesVideoCommentThreadExist (id: number, video: MVideoId, res: ex | |||
151 | return true | 152 | return true |
152 | } | 153 | } |
153 | 154 | ||
154 | async function doesVideoCommentExist (id: number, video: MVideoId, res: express.Response) { | 155 | async function doesVideoCommentExist (idArg: number | string, video: MVideoId, res: express.Response) { |
156 | const id = parseInt(idArg + '', 10) | ||
155 | const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) | 157 | const videoComment = await VideoCommentModel.loadByIdAndPopulateVideoAndAccountAndReply(id) |
156 | 158 | ||
157 | if (!videoComment) { | 159 | if (!videoComment) { |