]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/remote.js
c6455e678027a1e58bfd1594e778014b64f01dbb
[github/Chocobozzz/PeerTube.git] / server / middlewares / validators / remote.js
1 'use strict'
2
3 const checkErrors = require('./utils').checkErrors
4 const logger = require('../../helpers/logger')
5
6 const validatorsRemote = {
7 dataToDecrypt,
8 remoteVideos,
9 signature
10 }
11
12 function dataToDecrypt (req, res, next) {
13 req.checkBody('key', 'Should have a key').notEmpty()
14 req.checkBody('data', 'Should have data').notEmpty()
15
16 logger.debug('Checking dataToDecrypt parameters', { parameters: { keyLength: req.body.key.length, bodyLength: req.body.data.length } })
17
18 checkErrors(req, res, next)
19 }
20
21 function remoteVideos (req, res, next) {
22 req.checkBody('data').isEachRemoteVideosValid()
23
24 logger.debug('Checking remoteVideos parameters', { parameters: req.body })
25
26 checkErrors(req, res, next)
27 }
28
29 function signature (req, res, next) {
30 req.checkBody('signature.host', 'Should have a signature host').isURL()
31 req.checkBody('signature.signature', 'Should have a signature').notEmpty()
32
33 logger.debug('Checking signature parameters', { parameters: { signatureHost: req.body.signature.host } })
34
35 checkErrors(req, res, next)
36 }
37
38 // ---------------------------------------------------------------------------
39
40 module.exports = validatorsRemote