diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
commit | a6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch) | |
tree | 03204a408d56311692c3528bedcf95d2455e94f2 /server/middlewares/validators/pods.js | |
parent | 052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff) | |
parent | c4403b29ad4db097af528a7f04eea07e0ed320d0 (diff) | |
download | PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.gz PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.zst PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.zip |
Merge branch 'master' into webseed-merged
Diffstat (limited to 'server/middlewares/validators/pods.js')
-rw-r--r-- | server/middlewares/validators/pods.js | 34 |
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') | |||
5 | const logger = require('../../helpers/logger') | 5 | const logger = require('../../helpers/logger') |
6 | 6 | ||
7 | const validatorsPod = { | 7 | const validatorsPod = { |
8 | makeFriends: makeFriends, | 8 | makeFriends, |
9 | podsAdd: podsAdd | 9 | podsAdd |
10 | } | 10 | } |
11 | 11 | ||
12 | function makeFriends (req, res, next) { | 12 | function 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 | ||