X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fvideos.ts;h=10625e41d450a16f3b9a2b64188a39e7a51ab588;hb=8e7f08b5a5e65195ad6dd3d7850fda57021421f3;hp=3cbf98312bb0a71c5658e76abb1c5d70f907647d;hpb=a2431b7dcbc72c05101dcdbe631ff84a823aeb51;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/videos.ts b/server/middlewares/validators/videos.ts index 3cbf98312..10625e41d 100644 --- a/server/middlewares/validators/videos.ts +++ b/server/middlewares/validators/videos.ts @@ -6,7 +6,6 @@ import { isVideoAbuseReasonValid, isVideoCategoryValid, isVideoDescriptionValid, - isVideoDurationValid, isVideoExist, isVideoFile, isVideoLanguageValid, @@ -19,7 +18,7 @@ import { } from '../../helpers/custom-validators/videos' import { getDurationFromVideoFile } from '../../helpers/ffmpeg-utils' import { logger } from '../../helpers/logger' -import { CONSTRAINTS_FIELDS, SEARCHABLE_COLUMNS } from '../../initializers' +import { CONSTRAINTS_FIELDS } from '../../initializers' import { database as db } from '../../initializers/database' import { UserInstance } from '../../models/account/user-interface' import { VideoInstance } from '../../models/video/video-interface' @@ -32,11 +31,11 @@ const videosAddValidator = [ + CONSTRAINTS_FIELDS.VIDEOS.EXTNAME.join(', ') ), body('name').custom(isVideoNameValid).withMessage('Should have a valid name'), - body('category').custom(isVideoCategoryValid).withMessage('Should have a valid category'), - body('licence').custom(isVideoLicenceValid).withMessage('Should have a valid licence'), + body('category').optional().custom(isVideoCategoryValid).withMessage('Should have a valid category'), + body('licence').optional().custom(isVideoLicenceValid).withMessage('Should have a valid licence'), body('language').optional().custom(isVideoLanguageValid).withMessage('Should have a valid language'), body('nsfw').custom(isVideoNSFWValid).withMessage('Should have a valid NSFW attribute'), - body('description').custom(isVideoDescriptionValid).withMessage('Should have a valid description'), + body('description').optional().custom(isVideoDescriptionValid).withMessage('Should have a valid description'), body('channelId').custom(isIdValid).withMessage('Should have correct video channel id'), body('privacy').custom(isVideoPrivacyValid).withMessage('Should have correct video privacy'), body('tags').optional().custom(isVideoTagsValid).withMessage('Should have correct tags'), @@ -82,14 +81,6 @@ const videosAddValidator = [ return } - if (!isVideoDurationValid('' + duration)) { - return res.status(400) - .json({ - error: 'Duration of the video file is too big (max: ' + CONSTRAINTS_FIELDS.VIDEOS.DURATION.max + 's).' - }) - .end() - } - videoFile['duration'] = duration return next() @@ -181,8 +172,7 @@ const videosRemoveValidator = [ ] const videosSearchValidator = [ - param('value').not().isEmpty().withMessage('Should have a valid search'), - query('field').optional().isIn(SEARCHABLE_COLUMNS.VIDEOS).withMessage('Should have correct searchable column'), + query('search').not().isEmpty().withMessage('Should have a valid search'), (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking videosSearch parameters', { parameters: req.params }) @@ -231,7 +221,7 @@ const videosShareValidator = [ if (areValidationErrors(req, res)) return if (!await isVideoExist(req.params.id, res)) return - const share = await db.VideoShare.load(req.params.accountId, res.locals.video.id) + const share = await db.VideoShare.load(req.params.accountId, res.locals.video.id, undefined) if (!share) { return res.status(404) .end()