X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Frequests.js;h=b0cda09fe02452a520072f230288148ae5af3bbe;hb=a6fd2b30bf717eec14972a2175354781f5f43e77;hp=f76ff3473dfd7d9c0f7158b52663566298e4e9cf;hpb=e861452fb26553177ad4e32bfb18b4fd8a5b1816;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/requests.js b/server/helpers/requests.js index f76ff3473..b0cda09fe 100644 --- a/server/helpers/requests.js +++ b/server/helpers/requests.js @@ -7,8 +7,8 @@ const constants = require('../initializers/constants') const peertubeCrypto = require('./peertube-crypto') const requests = { - makeRetryRequest: makeRetryRequest, - makeSecureRequest: makeSecureRequest + makeRetryRequest, + makeSecureRequest } function makeRetryRequest (params, callback) { @@ -25,7 +25,7 @@ function makeRetryRequest (params, callback) { function makeSecureRequest (params, callback) { const requestParams = { - url: params.toPod.url + params.path + url: constants.REMOTE_SCHEME.HTTP + '://' + params.toPod.host + params.path } // Add data with POST requst ? @@ -34,29 +34,18 @@ function makeSecureRequest (params, callback) { // Add signature if it is specified in the params if (params.sign === true) { + const host = constants.CONFIG.WEBSERVER.HOST + requestParams.json.signature = { - url: constants.CONFIG.WEBSERVER.URL, - signature: peertubeCrypto.sign(constants.CONFIG.WEBSERVER.URL) + host, + signature: peertubeCrypto.sign(host) } } // If there are data informations if (params.data) { - // Encrypt data - if (params.encrypt === true) { - peertubeCrypto.encrypt(params.toPod.publicKey, JSON.stringify(params.data), function (err, encrypted) { - if (err) return callback(err) - - requestParams.json.data = encrypted.data - requestParams.json.key = encrypted.key - - request.post(requestParams, callback) - }) - } else { - // No encryption - requestParams.json.data = params.data - request.post(requestParams, callback) - } + requestParams.json.data = params.data + request.post(requestParams, callback) } else { // No data request.post(requestParams, callback)