From 6c1a098b4107cc923631d8cd94ed54c184fcec7d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 21 Aug 2016 09:54:46 +0200 Subject: Server: fix remote videos requests validator --- server/helpers/custom-validators/videos.js | 41 +++++++++++++++--------------- server/middlewares/validators/remote.js | 1 - 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'server') diff --git a/server/helpers/custom-validators/videos.js b/server/helpers/custom-validators/videos.js index cffa973f8..ebe927208 100644 --- a/server/helpers/custom-validators/videos.js +++ b/server/helpers/custom-validators/videos.js @@ -22,26 +22,27 @@ const videosValidators = { } function isEachRemoteVideosValid (requests) { - return requests.every(function (request) { - const video = request.data - return ( - isRequestTypeAddValid(request.type) && - isVideoAuthorValid(video.author) && - isVideoDateValid(video.createdDate) && - isVideoDescriptionValid(video.description) && - isVideoDurationValid(video.duration) && - isVideoMagnetUriValid(video.magnetUri) && - isVideoNameValid(video.name) && - isVideoPodUrlValid(video.podUrl) && - isVideoTagsValid(video.tags) && - isVideoThumbnail64Valid(video.thumbnailBase64) - ) || - ( - isRequestTypeRemoveValid(request.type) && - isVideoNameValid(video.name) && - isVideoMagnetUriValid(video.magnetUri) - ) - }) + return miscValidators.isArray(requests) && + requests.every(function (request) { + const video = request.data + return ( + isRequestTypeAddValid(request.type) && + isVideoAuthorValid(video.author) && + isVideoDateValid(video.createdDate) && + isVideoDescriptionValid(video.description) && + isVideoDurationValid(video.duration) && + isVideoMagnetUriValid(video.magnetUri) && + isVideoNameValid(video.name) && + isVideoPodUrlValid(video.podUrl) && + isVideoTagsValid(video.tags) && + isVideoThumbnail64Valid(video.thumbnailBase64) + ) || + ( + isRequestTypeRemoveValid(request.type) && + isVideoNameValid(video.name) && + isVideoMagnetUriValid(video.magnetUri) + ) + }) } function isVideoAuthorValid (value) { diff --git a/server/middlewares/validators/remote.js b/server/middlewares/validators/remote.js index 1be119458..87dc524a2 100644 --- a/server/middlewares/validators/remote.js +++ b/server/middlewares/validators/remote.js @@ -19,7 +19,6 @@ function dataToDecrypt (req, res, next) { } function remoteVideos (req, res, next) { - req.checkBody('data').isArray() req.checkBody('data').isEachRemoteVideosValid() logger.debug('Checking remoteVideos parameters', { parameters: req.body }) -- cgit v1.2.3