aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-06-18 16:13:54 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-06-18 16:13:54 +0200
commit528a9efa8272532bbd0dafc35c3e05e57c50f61e (patch)
tree62d4417df4ab9b2e53c44dc7271be81b88e4e0e5 /server/middlewares
parentb2e4c0ba1a33b8a50491a1f8d111468a7da5640f (diff)
downloadPeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.tar.gz
PeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.tar.zst
PeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.zip
Try to make a better communication (between pods) module
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/reqValidators/pods.js6
-rw-r--r--server/middlewares/reqValidators/remote.js26
2 files changed, 16 insertions, 16 deletions
diff --git a/server/middlewares/reqValidators/pods.js b/server/middlewares/reqValidators/pods.js
index 77449480c..78a4b76c1 100644
--- a/server/middlewares/reqValidators/pods.js
+++ b/server/middlewares/reqValidators/pods.js
@@ -26,8 +26,10 @@ function makeFriends (req, res, next) {
26} 26}
27 27
28function podsAdd (req, res, next) { 28function podsAdd (req, res, next) {
29 req.checkBody('data.url', 'Should have an url').notEmpty().isURL({ require_protocol: true }) 29 req.checkBody('url', 'Should have an url').notEmpty().isURL({ require_protocol: true })
30 req.checkBody('data.publicKey', 'Should have a public key').notEmpty() 30 req.checkBody('publicKey', 'Should have a public key').notEmpty()
31
32 // TODO: check we don't have it already
31 33
32 logger.debug('Checking podsAdd parameters', { parameters: req.body }) 34 logger.debug('Checking podsAdd parameters', { parameters: req.body })
33 35
diff --git a/server/middlewares/reqValidators/remote.js b/server/middlewares/reqValidators/remote.js
index b5f3118b0..a23673d89 100644
--- a/server/middlewares/reqValidators/remote.js
+++ b/server/middlewares/reqValidators/remote.js
@@ -4,36 +4,34 @@ const checkErrors = require('./utils').checkErrors
4const logger = require('../../helpers/logger') 4const logger = require('../../helpers/logger')
5 5
6const reqValidatorsRemote = { 6const reqValidatorsRemote = {
7 remoteVideosAdd: remoteVideosAdd, 7 dataToDecrypt: dataToDecrypt,
8 remoteVideosRemove: remoteVideosRemove, 8 remoteVideos: remoteVideos,
9 secureRequest: secureRequest 9 signature: signature
10} 10}
11 11
12function remoteVideosAdd (req, res, next) { 12function dataToDecrypt (req, res, next) {
13 req.checkBody('data').isArray() 13 req.checkBody('key', 'Should have a key').notEmpty()
14 req.checkBody('data').isEachAddRemoteVideosValid() 14 req.checkBody('data', 'Should have data').notEmpty()
15 15
16 logger.debug('Checking remoteVideosAdd parameters', { parameters: req.body }) 16 logger.debug('Checking dataToDecrypt parameters', { parameters: { keyLength: req.body.key.length, bodyLength: req.body.data.length } })
17 17
18 checkErrors(req, res, next) 18 checkErrors(req, res, next)
19} 19}
20 20
21function remoteVideosRemove (req, res, next) { 21function remoteVideos (req, res, next) {
22 req.checkBody('data').isArray() 22 req.checkBody('data').isArray()
23 req.checkBody('data').isEachRemoveRemoteVideosValid() 23 req.checkBody('data').isEachRemoteVideosValid()
24 24
25 logger.debug('Checking remoteVideosRemove parameters', { parameters: req.body }) 25 logger.debug('Checking remoteVideosAdd parameters', { parameters: req.body })
26 26
27 checkErrors(req, res, next) 27 checkErrors(req, res, next)
28} 28}
29 29
30function secureRequest (req, res, next) { 30function signature (req, res, next) {
31 req.checkBody('signature.url', 'Should have a signature url').isURL() 31 req.checkBody('signature.url', 'Should have a signature url').isURL()
32 req.checkBody('signature.signature', 'Should have a signature').notEmpty() 32 req.checkBody('signature.signature', 'Should have a signature').notEmpty()
33 req.checkBody('key', 'Should have a key').notEmpty()
34 req.checkBody('data', 'Should have data').notEmpty()
35 33
36 logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } }) 34 logger.debug('Checking signature parameters', { parameters: { signatureUrl: req.body.signature.url } })
37 35
38 checkErrors(req, res, next) 36 checkErrors(req, res, next)
39} 37}