aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/pods.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/pods.ts')
-rw-r--r--server/middlewares/validators/pods.ts44
1 files changed, 22 insertions, 22 deletions
diff --git a/server/middlewares/validators/pods.ts b/server/middlewares/validators/pods.ts
index d8eb90168..da7fc2bd6 100644
--- a/server/middlewares/validators/pods.ts
+++ b/server/middlewares/validators/pods.ts
@@ -19,19 +19,19 @@ function makeFriendsValidator (req: express.Request, res: express.Response, next
19 logger.debug('Checking makeFriends parameters', { parameters: req.body }) 19 logger.debug('Checking makeFriends parameters', { parameters: req.body })
20 20
21 checkErrors(req, res, function () { 21 checkErrors(req, res, function () {
22 hasFriends(function (err, heHasFriends) { 22 hasFriends()
23 if (err) { 23 .then(heHasFriends => {
24 if (heHasFriends === true) {
25 // We need to quit our friends before make new ones
26 return res.sendStatus(409)
27 }
28
29 return next()
30 })
31 .catch(err => {
24 logger.error('Cannot know if we have friends.', { error: err }) 32 logger.error('Cannot know if we have friends.', { error: err })
25 res.sendStatus(500) 33 res.sendStatus(500)
26 } 34 })
27
28 if (heHasFriends === true) {
29 // We need to quit our friends before make new ones
30 return res.sendStatus(409)
31 }
32
33 return next()
34 })
35 }) 35 })
36} 36}
37 37
@@ -42,19 +42,19 @@ function podsAddValidator (req: express.Request, res: express.Response, next: ex
42 logger.debug('Checking podsAdd parameters', { parameters: req.body }) 42 logger.debug('Checking podsAdd parameters', { parameters: req.body })
43 43
44 checkErrors(req, res, function () { 44 checkErrors(req, res, function () {
45 db.Pod.loadByHost(req.body.host, function (err, pod) { 45 db.Pod.loadByHost(req.body.host)
46 if (err) { 46 .then(pod => {
47 // Pod with this host already exists
48 if (pod) {
49 return res.sendStatus(409)
50 }
51
52 return next()
53 })
54 .catch(err => {
47 logger.error('Cannot load pod by host.', { error: err }) 55 logger.error('Cannot load pod by host.', { error: err })
48 res.sendStatus(500) 56 res.sendStatus(500)
49 } 57 })
50
51 // Pod with this host already exists
52 if (pod) {
53 return res.sendStatus(409)
54 }
55
56 return next()
57 })
58 }) 58 })
59} 59}
60 60