From 019e47507212072a7b91fb18dd31b4170d9cb40c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 Jul 2018 16:51:17 +0200 Subject: Remove unnecessary image check in video upload --- server/middlewares/validators/videos.ts | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'server') diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index a2f64ef8f..abb23b510 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts @@ -51,7 +51,6 @@ const videosAddValidator = getCommonVideoAttributes().concat([ logger.debug('Checking videosAdd parameters', { parameters: req.body, files: req.files }) if (areValidationErrors(req, res)) return - if (areErrorsInVideoImageFiles(req, res)) return if (areErrorsInScheduleUpdate(req, res)) return const videoFile: Express.Multer.File = req.files['videofile'][0] @@ -101,7 +100,6 @@ const videosUpdateValidator = getCommonVideoAttributes().concat([ logger.debug('Checking videosUpdate parameters', { parameters: req.body }) if (areValidationErrors(req, res)) return - if (areErrorsInVideoImageFiles(req, res)) return if (areErrorsInScheduleUpdate(req, res)) return if (!await isVideoExist(req.params.id, res)) return @@ -252,25 +250,6 @@ export { // --------------------------------------------------------------------------- -function areErrorsInVideoImageFiles (req: express.Request, res: express.Response) { - // Files are optional - if (!req.files) return false - - for (const imageField of [ 'thumbnail', 'preview' ]) { - if (!req.files[ imageField ]) continue - - const imageFile = req.files[ imageField ][ 0 ] as Express.Multer.File - if (imageFile.size > CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max) { - res.status(400) - .json({ error: `The size of the ${imageField} is too big (>${CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max}).` }) - .end() - return true - } - } - - return false -} - function areErrorsInScheduleUpdate (req: express.Request, res: express.Response) { if (req.body.scheduleUpdate) { if (!req.body.scheduleUpdate.updateAt) { -- cgit v1.2.3