diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-02-07 11:23:23 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-02-07 11:23:23 +0100 |
commit | 9f10b2928df655c3672d9607e864e667d4bc903a (patch) | |
tree | 7743911b974b3a7fb0d4c7cec2a723942466b7f1 /middlewares/reqValidators/pods.js | |
parent | d7c01e7793d813d804a3b5716d8288f9dcf71a16 (diff) | |
download | PeerTube-9f10b2928df655c3672d9607e864e667d4bc903a.tar.gz PeerTube-9f10b2928df655c3672d9607e864e667d4bc903a.tar.zst PeerTube-9f10b2928df655c3672d9607e864e667d4bc903a.zip |
Remove useless anonymous functions of files
Diffstat (limited to 'middlewares/reqValidators/pods.js')
-rw-r--r-- | middlewares/reqValidators/pods.js | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/middlewares/reqValidators/pods.js b/middlewares/reqValidators/pods.js index 4d649b486..7d1612dde 100644 --- a/middlewares/reqValidators/pods.js +++ b/middlewares/reqValidators/pods.js | |||
@@ -1,41 +1,39 @@ | |||
1 | ;(function () { | 1 | 'use strict' |
2 | 'use strict' | 2 | |
3 | 3 | var checkErrors = require('./utils').checkErrors | |
4 | var checkErrors = require('./utils').checkErrors | 4 | var friends = require('../../lib/friends') |
5 | var friends = require('../../lib/friends') | 5 | var logger = require('../../helpers/logger') |
6 | var logger = require('../../helpers/logger') | 6 | |
7 | 7 | var reqValidatorsPod = { | |
8 | var reqValidatorsPod = { | 8 | makeFriends: makeFriends, |
9 | makeFriends: makeFriends, | 9 | podsAdd: podsAdd |
10 | podsAdd: podsAdd | 10 | } |
11 | } | 11 | |
12 | 12 | function makeFriends (req, res, next) { | |
13 | function makeFriends (req, res, next) { | 13 | friends.hasFriends(function (err, has_friends) { |
14 | friends.hasFriends(function (err, has_friends) { | 14 | if (err) { |
15 | if (err) { | 15 | logger.error('Cannot know if we have friends.', { error: err }) |
16 | logger.error('Cannot know if we have friends.', { error: err }) | 16 | res.sendStatus(500) |
17 | res.sendStatus(500) | 17 | } |
18 | } | 18 | |
19 | 19 | if (has_friends === true) { | |
20 | if (has_friends === true) { | 20 | // We need to quit our friends before make new ones |
21 | // We need to quit our friends before make new ones | 21 | res.sendStatus(409) |
22 | res.sendStatus(409) | 22 | } else { |
23 | } else { | 23 | next() |
24 | next() | 24 | } |
25 | } | 25 | }) |
26 | }) | 26 | } |
27 | } | 27 | |
28 | 28 | function podsAdd (req, res, next) { | |
29 | function podsAdd (req, res, next) { | 29 | req.checkBody('data.url', 'Should have an url').notEmpty().isURL({ require_protocol: true }) |
30 | req.checkBody('data.url', 'Should have an url').notEmpty().isURL({ require_protocol: true }) | 30 | req.checkBody('data.publicKey', 'Should have a public key').notEmpty() |
31 | req.checkBody('data.publicKey', 'Should have a public key').notEmpty() | 31 | |
32 | 32 | logger.debug('Checking podsAdd parameters', { parameters: req.body }) | |
33 | logger.debug('Checking podsAdd parameters', { parameters: req.body }) | 33 | |
34 | 34 | checkErrors(req, res, next) | |
35 | checkErrors(req, res, next) | 35 | } |
36 | } | 36 | |
37 | 37 | // --------------------------------------------------------------------------- | |
38 | // --------------------------------------------------------------------------- | 38 | |
39 | 39 | module.exports = reqValidatorsPod | |
40 | module.exports = reqValidatorsPod | ||
41 | })() | ||