]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Server: fix remote videos requests validator
authorChocobozzz <florian.bigard@gmail.com>
Sun, 21 Aug 2016 07:54:46 +0000 (09:54 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Sun, 21 Aug 2016 07:54:46 +0000 (09:54 +0200)
server/helpers/custom-validators/videos.js
server/middlewares/validators/remote.js

index cffa973f8f68927bf28f78daf07b7c86a9d480a3..ebe927208b75166061b0c367e47266c79d4be75a 100644 (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) {
index 1be119458dd2c37235c2ffb31a561e0d81150fd8..87dc524a2bcc0e2b5620b3178ed1143cdd4bff35 100644 (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 })