2016-02-07 11:23:23 +01:00
|
|
|
'use strict'
|
2015-11-07 14:16:26 +01:00
|
|
|
|
2016-03-16 22:29:27 +01:00
|
|
|
const checkErrors = require('./utils').checkErrors
|
|
|
|
const logger = require('../../helpers/logger')
|
2015-11-07 14:16:26 +01:00
|
|
|
|
2016-03-16 22:29:27 +01:00
|
|
|
const reqValidatorsRemote = {
|
2016-02-07 11:23:23 +01:00
|
|
|
remoteVideosAdd: remoteVideosAdd,
|
|
|
|
remoteVideosRemove: remoteVideosRemove,
|
|
|
|
secureRequest: secureRequest
|
|
|
|
}
|
2015-11-07 14:16:26 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
function remoteVideosAdd (req, res, next) {
|
|
|
|
req.checkBody('data').isArray()
|
|
|
|
req.checkBody('data').eachIsRemoteVideosAddValid()
|
2015-11-07 14:16:26 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
logger.debug('Checking remoteVideosAdd parameters', { parameters: req.body })
|
2015-11-07 14:16:26 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
checkErrors(req, res, next)
|
|
|
|
}
|
2015-11-07 14:16:26 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
function remoteVideosRemove (req, res, next) {
|
|
|
|
req.checkBody('data').isArray()
|
|
|
|
req.checkBody('data').eachIsRemoteVideosRemoveValid()
|
2015-11-07 14:16:26 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
logger.debug('Checking remoteVideosRemove parameters', { parameters: req.body })
|
2015-11-07 14:16:26 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
checkErrors(req, res, next)
|
|
|
|
}
|
2015-11-07 14:16:26 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
function secureRequest (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()
|
2016-01-31 11:23:52 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } })
|
2016-01-31 11:23:52 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
checkErrors(req, res, next)
|
|
|
|
}
|
2016-01-31 11:23:52 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
// ---------------------------------------------------------------------------
|
2016-01-31 11:23:52 +01:00
|
|
|
|
2016-02-07 11:23:23 +01:00
|
|
|
module.exports = reqValidatorsRemote
|