aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pods.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2015-12-14 21:09:25 +0100
committerChocobozzz <florian.bigard@gmail.com>2015-12-14 22:13:03 +0100
commit656ea8f70e848b03c0b668584dd533d72b376498 (patch)
treefa49512e3a3702a80d027838e5ab7486baca185a /src/pods.js
parent1d7974c758d363a0037c2a7ed05a0848d3c027a4 (diff)
downloadPeerTube-656ea8f70e848b03c0b668584dd533d72b376498.tar.gz
PeerTube-656ea8f70e848b03c0b668584dd533d72b376498.tar.zst
PeerTube-656ea8f70e848b03c0b668584dd533d72b376498.zip
Create a constants module to easily modify some constants in a test
instance for example.
Diffstat (limited to 'src/pods.js')
-rw-r--r--src/pods.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/pods.js b/src/pods.js
index a0dbb6b68..8da216a55 100644
--- a/src/pods.js
+++ b/src/pods.js
@@ -6,6 +6,7 @@
6 var fs = require('fs') 6 var fs = require('fs')
7 var request = require('request') 7 var request = require('request')
8 8
9 var constants = require('./constants')
9 var logger = require('./logger') 10 var logger = require('./logger')
10 var PodsDB = require('./database').PodsDB 11 var PodsDB = require('./database').PodsDB
11 var poolRequests = require('./poolRequests') 12 var poolRequests = require('./poolRequests')
@@ -20,7 +21,7 @@
20 // ----------- Private functions ----------- 21 // ----------- Private functions -----------
21 22
22 function getForeignPodsList (url, callback) { 23 function getForeignPodsList (url, callback) {
23 var path = '/api/' + global.API_VERSION + '/pods' 24 var path = '/api/' + constants.API_VERSION + '/pods'
24 25
25 request.get(url + path, function (err, response, body) { 26 request.get(url + path, function (err, response, body) {
26 if (err) throw err 27 if (err) throw err
@@ -48,7 +49,7 @@
48 var params = { 49 var params = {
49 url: data.url, 50 url: data.url,
50 publicKey: data.publicKey, 51 publicKey: data.publicKey,
51 score: global.FRIEND_BASE_SCORE 52 score: constants.FRIEND_BASE_SCORE
52 } 53 }
53 54
54 PodsDB.create(params, function (err, pod) { 55 PodsDB.create(params, function (err, pod) {
@@ -142,14 +143,14 @@
142 } 143 }
143 144
144 utils.makeMultipleRetryRequest( 145 utils.makeMultipleRetryRequest(
145 { method: 'POST', path: '/api/' + global.API_VERSION + '/pods/', data: data }, 146 { method: 'POST', path: '/api/' + constants.API_VERSION + '/pods/', data: data },
146 147
147 pods_list, 148 pods_list,
148 149
149 function eachRequest (err, response, body, url, pod, callback_each_request) { 150 function eachRequest (err, response, body, url, pod, callback_each_request) {
150 // We add the pod if it responded correctly with its public certificate 151 // We add the pod if it responded correctly with its public certificate
151 if (!err && response.statusCode === 200) { 152 if (!err && response.statusCode === 200) {
152 pods.add({ url: pod.url, publicKey: body.cert, score: global.FRIEND_BASE_SCORE }, function (err) { 153 pods.add({ url: pod.url, publicKey: body.cert, score: constants.FRIEND_BASE_SCORE }, function (err) {
153 if (err) { 154 if (err) {
154 logger.error('Error with adding %s pod.', pod.url, { error: err }) 155 logger.error('Error with adding %s pod.', pod.url, { error: err })
155 } 156 }