]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/pods.js
7c4d04affc8b497cab3d2a703ed879a86543a401
3 const checkErrors
= require('./utils').checkErrors
4 const friends
= require('../../lib/friends')
5 const logger
= require('../../helpers/logger')
7 const validatorsPod
= {
8 makeFriends: makeFriends
,
12 function makeFriends (req
, res
, next
) {
13 req
.checkBody('urls', 'Should have an array of urls').isArray()
14 req
.checkBody('urls', 'Should be an url').isEachUrl()
16 logger
.debug('Checking makeFriends parameters', { parameters: req
.body
})
18 friends
.hasFriends(function (err
, hasFriends
) {
20 logger
.error('Cannot know if we have friends.', { error: err
})
24 if (hasFriends
=== true) {
25 // We need to quit our friends before make new ones
33 function podsAdd (req
, res
, next
) {
34 req
.checkBody('url', 'Should have an url').notEmpty().isURL({ require_protocol: true })
35 req
.checkBody('publicKey', 'Should have a public key').notEmpty()
37 // TODO: check we don't have it already
39 logger
.debug('Checking podsAdd parameters', { parameters: req
.body
})
41 checkErrors(req
, res
, next
)
44 // ---------------------------------------------------------------------------
46 module
.exports
= validatorsPod