aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/requests.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-11 21:19:34 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-13 14:23:11 +0200
commitbc503c2a62dcf9aed6b8d90b68f0f27a7755ac01 (patch)
treea1fe1ad88afd29ee4d7cb05c480649d5a9c6f9a0 /server/helpers/requests.js
parent881a5e68b64e4acd43408852bbdc914643d8fac6 (diff)
downloadPeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.tar.gz
PeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.tar.zst
PeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.zip
Update to standard 7. Goodbye snake_case, I used to love you
Diffstat (limited to 'server/helpers/requests.js')
-rw-r--r--server/helpers/requests.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/server/helpers/requests.js b/server/helpers/requests.js
index 17b1127c0..1e1bb4111 100644
--- a/server/helpers/requests.js
+++ b/server/helpers/requests.js
@@ -17,7 +17,7 @@ const requests = {
17 makeMultipleRetryRequest: makeMultipleRetryRequest 17 makeMultipleRetryRequest: makeMultipleRetryRequest
18} 18}
19 19
20function makeMultipleRetryRequest (all_data, pods, callbackEach, callback) { 20function makeMultipleRetryRequest (allData, pods, callbackEach, callback) {
21 if (!callback) { 21 if (!callback) {
22 callback = callbackEach 22 callback = callbackEach
23 callbackEach = null 23 callbackEach = null
@@ -27,32 +27,32 @@ function makeMultipleRetryRequest (all_data, pods, callbackEach, callback) {
27 let signature 27 let signature
28 28
29 // Add signature if it is specified in the params 29 // Add signature if it is specified in the params
30 if (all_data.method === 'POST' && all_data.data && all_data.sign === true) { 30 if (allData.method === 'POST' && allData.data && allData.sign === true) {
31 signature = peertubeCrypto.sign(url) 31 signature = peertubeCrypto.sign(url)
32 } 32 }
33 33
34 // Make a request for each pod 34 // Make a request for each pod
35 async.each(pods, function (pod, callback_each_async) { 35 async.each(pods, function (pod, callbackEachAsync) {
36 function callbackEachRetryRequest (err, response, body, url, pod) { 36 function callbackEachRetryRequest (err, response, body, url, pod) {
37 if (callbackEach !== null) { 37 if (callbackEach !== null) {
38 callbackEach(err, response, body, url, pod, function () { 38 callbackEach(err, response, body, url, pod, function () {
39 callback_each_async() 39 callbackEachAsync()
40 }) 40 })
41 } else { 41 } else {
42 callback_each_async() 42 callbackEachAsync()
43 } 43 }
44 } 44 }
45 45
46 const params = { 46 const params = {
47 url: pod.url + all_data.path, 47 url: pod.url + allData.path,
48 method: all_data.method 48 method: allData.method
49 } 49 }
50 50
51 // Add data with POST requst ? 51 // Add data with POST requst ?
52 if (all_data.method === 'POST' && all_data.data) { 52 if (allData.method === 'POST' && allData.data) {
53 // Encrypt data ? 53 // Encrypt data ?
54 if (all_data.encrypt === true) { 54 if (allData.encrypt === true) {
55 peertubeCrypto.encrypt(pod.publicKey, JSON.stringify(all_data.data), function (err, encrypted) { 55 peertubeCrypto.encrypt(pod.publicKey, JSON.stringify(allData.data), function (err, encrypted) {
56 if (err) return callback(err) 56 if (err) return callback(err)
57 57
58 params.json = { 58 params.json = {
@@ -63,7 +63,7 @@ function makeMultipleRetryRequest (all_data, pods, callbackEach, callback) {
63 makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest) 63 makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest)
64 }) 64 })
65 } else { 65 } else {
66 params.json = { data: all_data.data } 66 params.json = { data: allData.data }
67 makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest) 67 makeRetryRequest(params, url, pod, signature, callbackEachRetryRequest)
68 } 68 }
69 } else { 69 } else {
@@ -78,20 +78,20 @@ module.exports = requests
78 78
79// --------------------------------------------------------------------------- 79// ---------------------------------------------------------------------------
80 80
81function makeRetryRequest (params, from_url, to_pod, signature, callbackEach) { 81function makeRetryRequest (params, fromUrl, toPod, signature, callbackEach) {
82 // Append the signature 82 // Append the signature
83 if (signature) { 83 if (signature) {
84 params.json.signature = { 84 params.json.signature = {
85 url: from_url, 85 url: fromUrl,
86 signature: signature 86 signature: signature
87 } 87 }
88 } 88 }
89 89
90 logger.debug('Make retry requests to %s.', to_pod.url) 90 logger.debug('Make retry requests to %s.', toPod.url)
91 91
92 replay( 92 replay(
93 request.post(params, function (err, response, body) { 93 request.post(params, function (err, response, body) {
94 callbackEach(err, response, body, params.url, to_pod) 94 callbackEach(err, response, body, params.url, toPod)
95 }), 95 }),
96 { 96 {
97 retries: constants.REQUEST_RETRIES, 97 retries: constants.REQUEST_RETRIES,