diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-02-04 21:10:33 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-02-04 21:10:33 +0100 |
commit | c173e56520b0fe4206b9ea8049b6add40bfeabcd (patch) | |
tree | 264c6cbf1bf81a6522685b4be5771bbeef4cd5dc /middlewares/reqValidators/pods.js | |
parent | c45f7f84001c2731909db04dd82e1c1f290386eb (diff) | |
download | PeerTube-c173e56520b0fe4206b9ea8049b6add40bfeabcd.tar.gz PeerTube-c173e56520b0fe4206b9ea8049b6add40bfeabcd.tar.zst PeerTube-c173e56520b0fe4206b9ea8049b6add40bfeabcd.zip |
Split models
Diffstat (limited to 'middlewares/reqValidators/pods.js')
-rw-r--r-- | middlewares/reqValidators/pods.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/middlewares/reqValidators/pods.js b/middlewares/reqValidators/pods.js index 6ccfd7361..499cafd8f 100644 --- a/middlewares/reqValidators/pods.js +++ b/middlewares/reqValidators/pods.js | |||
@@ -2,12 +2,27 @@ | |||
2 | 'use strict' | 2 | 'use strict' |
3 | 3 | ||
4 | var checkErrors = require('./utils').checkErrors | 4 | var checkErrors = require('./utils').checkErrors |
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 = { |
9 | makeFriends: makeFriends, | ||
8 | podsAdd: podsAdd | 10 | podsAdd: podsAdd |
9 | } | 11 | } |
10 | 12 | ||
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 | |||
11 | function podsAdd (req, res, next) { | 26 | function podsAdd (req, res, next) { |
12 | req.checkBody('data.url', 'Should have an url').notEmpty().isURL({ require_protocol: true }) | 27 | req.checkBody('data.url', 'Should have an url').notEmpty().isURL({ require_protocol: true }) |
13 | req.checkBody('data.publicKey', 'Should have a public key').notEmpty() | 28 | req.checkBody('data.publicKey', 'Should have a public key').notEmpty() |