]>
Commit | Line | Data |
---|---|---|
34ca3b52 C |
1 | ;(function () { |
2 | 'use strict' | |
3 | ||
4 | var checkErrors = require('./utils').checkErrors | |
c173e565 | 5 | var friends = require('../../lib/friends') |
cda02107 | 6 | var logger = require('../../helpers/logger') |
34ca3b52 | 7 | |
c45f7f84 | 8 | var reqValidatorsPod = { |
c173e565 | 9 | makeFriends: makeFriends, |
c45f7f84 C |
10 | podsAdd: podsAdd |
11 | } | |
34ca3b52 | 12 | |
c173e565 C |
13 | function makeFriends (req, res, next) { |
14 | friends.hasFriends(function (err, has_friends) { | |
15 | if (err) return next(err) | |
16 | ||
17 | if (has_friends === true) { | |
18 | // We need to quit our friends before make new ones | |
19 | res.sendStatus(409) | |
20 | } else { | |
21 | next() | |
22 | } | |
23 | }) | |
24 | } | |
25 | ||
c45f7f84 | 26 | function podsAdd (req, res, next) { |
34ca3b52 C |
27 | req.checkBody('data.url', 'Should have an url').notEmpty().isURL({ require_protocol: true }) |
28 | req.checkBody('data.publicKey', 'Should have a public key').notEmpty() | |
29 | ||
30 | logger.debug('Checking podsAdd parameters', { parameters: req.body }) | |
31 | ||
32 | checkErrors(req, res, next) | |
33 | } | |
34 | ||
c45f7f84 C |
35 | // --------------------------------------------------------------------------- |
36 | ||
37 | module.exports = reqValidatorsPod | |
34ca3b52 | 38 | })() |