aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/pods.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/pods.js')
-rw-r--r--server/middlewares/validators/pods.js34
1 files changed, 20 insertions, 14 deletions
diff --git a/server/middlewares/validators/pods.js b/server/middlewares/validators/pods.js
index fda2e865f..fd3d1e2f2 100644
--- a/server/middlewares/validators/pods.js
+++ b/server/middlewares/validators/pods.js
@@ -5,23 +5,29 @@ const friends = require('../../lib/friends')
5const logger = require('../../helpers/logger') 5const logger = require('../../helpers/logger')
6 6
7const validatorsPod = { 7const validatorsPod = {
8 makeFriends: makeFriends, 8 makeFriends,
9 podsAdd: podsAdd 9 podsAdd
10} 10}
11 11
12function makeFriends (req, res, next) { 12function makeFriends (req, res, next) {
13 friends.hasFriends(function (err, hasFriends) { 13 req.checkBody('urls', 'Should have an array of unique urls').isEachUniqueUrlValid()
14 if (err) { 14
15 logger.error('Cannot know if we have friends.', { error: err }) 15 logger.debug('Checking makeFriends parameters', { parameters: req.body })
16 res.sendStatus(500) 16
17 } 17 checkErrors(req, res, function () {
18 18 friends.hasFriends(function (err, hasFriends) {
19 if (hasFriends === true) { 19 if (err) {
20 // We need to quit our friends before make new ones 20 logger.error('Cannot know if we have friends.', { error: err })
21 res.sendStatus(409) 21 res.sendStatus(500)
22 } else { 22 }
23 return next() 23
24 } 24 if (hasFriends === true) {
25 // We need to quit our friends before make new ones
26 res.sendStatus(409)
27 } else {
28 return next()
29 }
30 })
25 }) 31 })
26} 32}
27 33