]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/middlewares/reqValidators/pods.js
Try to make a better communication (between pods) module
[github/Chocobozzz/PeerTube.git] / server / middlewares / reqValidators / pods.js
index ef09d51cf84e2a4d119803c1662544e9100cdd68..78a4b76c13ef99cc76aed41a8a4cbae86bd0f2c8 100644 (file)
@@ -1,22 +1,22 @@
 'use strict'
 
-var checkErrors = require('./utils').checkErrors
-var friends = require('../../lib/friends')
-var logger = require('../../helpers/logger')
+const checkErrors = require('./utils').checkErrors
+const friends = require('../../lib/friends')
+const logger = require('../../helpers/logger')
 
-var reqValidatorsPod = {
+const reqValidatorsPod = {
   makeFriends: makeFriends,
   podsAdd: podsAdd
 }
 
 function makeFriends (req, res, next) {
-  friends.hasFriends(function (err, has_friends) {
+  friends.hasFriends(function (err, hasFriends) {
     if (err) {
       logger.error('Cannot know if we have friends.', { error: err })
       res.sendStatus(500)
     }
 
-    if (has_friends === true) {
+    if (hasFriends === true) {
       // We need to quit our friends before make new ones
       res.sendStatus(409)
     } else {
@@ -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 })