From 528a9efa8272532bbd0dafc35c3e05e57c50f61e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 18 Jun 2016 16:13:54 +0200 Subject: Try to make a better communication (between pods) module --- server/middlewares/reqValidators/pods.js | 6 ++++-- server/middlewares/reqValidators/remote.js | 26 ++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'server/middlewares/reqValidators') 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) { } function podsAdd (req, res, next) { - req.checkBody('data.url', 'Should have an url').notEmpty().isURL({ require_protocol: true }) - req.checkBody('data.publicKey', 'Should have a public key').notEmpty() + req.checkBody('url', 'Should have an url').notEmpty().isURL({ require_protocol: true }) + req.checkBody('publicKey', 'Should have a public key').notEmpty() + + // TODO: check we don't have it already logger.debug('Checking podsAdd parameters', { parameters: req.body }) 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 const logger = require('../../helpers/logger') const reqValidatorsRemote = { - remoteVideosAdd: remoteVideosAdd, - remoteVideosRemove: remoteVideosRemove, - secureRequest: secureRequest + dataToDecrypt: dataToDecrypt, + remoteVideos: remoteVideos, + signature: signature } -function remoteVideosAdd (req, res, next) { - req.checkBody('data').isArray() - req.checkBody('data').isEachAddRemoteVideosValid() +function dataToDecrypt (req, res, next) { + req.checkBody('key', 'Should have a key').notEmpty() + req.checkBody('data', 'Should have data').notEmpty() - logger.debug('Checking remoteVideosAdd parameters', { parameters: req.body }) + logger.debug('Checking dataToDecrypt parameters', { parameters: { keyLength: req.body.key.length, bodyLength: req.body.data.length } }) checkErrors(req, res, next) } -function remoteVideosRemove (req, res, next) { +function remoteVideos (req, res, next) { req.checkBody('data').isArray() - req.checkBody('data').isEachRemoveRemoteVideosValid() + req.checkBody('data').isEachRemoteVideosValid() - logger.debug('Checking remoteVideosRemove parameters', { parameters: req.body }) + logger.debug('Checking remoteVideosAdd parameters', { parameters: req.body }) checkErrors(req, res, next) } -function secureRequest (req, res, next) { +function signature (req, res, next) { req.checkBody('signature.url', 'Should have a signature url').isURL() req.checkBody('signature.signature', 'Should have a signature').notEmpty() - req.checkBody('key', 'Should have a key').notEmpty() - req.checkBody('data', 'Should have data').notEmpty() - logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } }) + logger.debug('Checking signature parameters', { parameters: { signatureUrl: req.body.signature.url } }) checkErrors(req, res, next) } -- cgit v1.2.3