Server: fix remote videos requests validator

This commit is contained in:
Chocobozzz 2016-08-21 09:54:46 +02:00
parent 4613274479
commit 6c1a098b41
2 changed files with 21 additions and 21 deletions

View File

@ -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) {

View File

@ -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 })