aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/pods.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-21 10:08:40 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-21 10:41:04 +0200
commitd57d6f2605f4ac4a81f9a8594433bb7b65f108b9 (patch)
tree4fd2c1a4930df841c16fad5858f4a93330add715 /server/middlewares/validators/pods.js
parent6c1a098b4107cc923631d8cd94ed54c184fcec7d (diff)
downloadPeerTube-d57d6f2605f4ac4a81f9a8594433bb7b65f108b9.tar.gz
PeerTube-d57d6f2605f4ac4a81f9a8594433bb7b65f108b9.tar.zst
PeerTube-d57d6f2605f4ac4a81f9a8594433bb7b65f108b9.zip
Server: fix makefriends validation and tests
Diffstat (limited to 'server/middlewares/validators/pods.js')
-rw-r--r--server/middlewares/validators/pods.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/server/middlewares/validators/pods.js b/server/middlewares/validators/pods.js
index 7c4d04aff..3c605c45e 100644
--- a/server/middlewares/validators/pods.js
+++ b/server/middlewares/validators/pods.js
@@ -10,23 +10,24 @@ const validatorsPod = {
10} 10}
11 11
12function makeFriends (req, res, next) { 12function makeFriends (req, res, next) {
13 req.checkBody('urls', 'Should have an array of urls').isArray() 13 req.checkBody('urls', 'Should have an array of unique urls').isEachUniqueUrlValid()
14 req.checkBody('urls', 'Should be an url').isEachUrl()
15 14
16 logger.debug('Checking makeFriends parameters', { parameters: req.body }) 15 logger.debug('Checking makeFriends parameters', { parameters: req.body })
17 16
18 friends.hasFriends(function (err, hasFriends) { 17 checkErrors(req, res, function () {
19 if (err) { 18 friends.hasFriends(function (err, hasFriends) {
20 logger.error('Cannot know if we have friends.', { error: err }) 19 if (err) {
21 res.sendStatus(500) 20 logger.error('Cannot know if we have friends.', { error: err })
22 } 21 res.sendStatus(500)
23 22 }
24 if (hasFriends === true) { 23
25 // We need to quit our friends before make new ones 24 if (hasFriends === true) {
26 res.sendStatus(409) 25 // We need to quit our friends before make new ones
27 } else { 26 res.sendStatus(409)
28 return next() 27 } else {
29 } 28 return next()
29 }
30 })
30 }) 31 })
31} 32}
32 33