diff options
Diffstat (limited to 'server/middlewares/validators/pods.js')
-rw-r--r-- | server/middlewares/validators/pods.js | 29 |
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 | ||
12 | function makeFriends (req, res, next) { | 12 | function 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 | ||