aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/pods.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-07-01 16:16:40 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-07-01 16:16:40 +0200
commitfc51fde048f2c3ce1dd3e85f5528335040bae894 (patch)
tree6de1eeac1291d9398cc99cda926b189c39b3ea0b /server/middlewares/validators/pods.js
parent69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd (diff)
downloadPeerTube-fc51fde048f2c3ce1dd3e85f5528335040bae894.tar.gz
PeerTube-fc51fde048f2c3ce1dd3e85f5528335040bae894.tar.zst
PeerTube-fc51fde048f2c3ce1dd3e85f5528335040bae894.zip
reqValidators --> validators
Diffstat (limited to 'server/middlewares/validators/pods.js')
-rw-r--r--server/middlewares/validators/pods.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/server/middlewares/validators/pods.js b/server/middlewares/validators/pods.js
new file mode 100644
index 000000000..fda2e865f
--- /dev/null
+++ b/server/middlewares/validators/pods.js
@@ -0,0 +1,41 @@
1'use strict'
2
3const checkErrors = require('./utils').checkErrors
4const friends = require('../../lib/friends')
5const logger = require('../../helpers/logger')
6
7const validatorsPod = {
8 makeFriends: makeFriends,
9 podsAdd: podsAdd
10}
11
12function makeFriends (req, res, next) {
13 friends.hasFriends(function (err, hasFriends) {
14 if (err) {
15 logger.error('Cannot know if we have friends.', { error: err })
16 res.sendStatus(500)
17 }
18
19 if (hasFriends === true) {
20 // We need to quit our friends before make new ones
21 res.sendStatus(409)
22 } else {
23 return next()
24 }
25 })
26}
27
28function podsAdd (req, res, next) {
29 req.checkBody('url', 'Should have an url').notEmpty().isURL({ require_protocol: true })
30 req.checkBody('publicKey', 'Should have a public key').notEmpty()
31
32 // TODO: check we don't have it already
33
34 logger.debug('Checking podsAdd parameters', { parameters: req.body })
35
36 checkErrors(req, res, next)
37}
38
39// ---------------------------------------------------------------------------
40
41module.exports = validatorsPod