- requests.makeMultipleRetryRequest(
- { method: 'POST', path: '/api/' + constants.API_VERSION + '/pods/', data: data },
-
- podsList,
-
- function eachRequest (err, response, body, url, pod, callbackEachRequest) {
- // We add the pod if it responded correctly with its public certificate
- if (!err && response.statusCode === 200) {
- Pods.add({ url: pod.url, publicKey: body.cert, score: constants.FRIEND_BASE_SCORE }, function (err) {
- if (err) {
- logger.error('Error with adding %s pod.', pod.url, { error: err })
- return callbackEachRequest()
- }
-
- videos.createRemoteVideos(body.videos, function (err) {
- if (err) {
- logger.error('Error with adding videos of pod.', pod.url, { error: err })
- return callbackEachRequest()
- }
-
- logger.debug('Adding remote videos from %s.', pod.url, { videos: body.videos })
- return callbackEachRequest()
- })
- })
- } else {
- logger.error('Error with adding %s pod.', pod.url, { error: err || new Error('Status not 200') })
- return callbackEachRequest()
- }
- },
+ if (res.statusCode === 200) {
+ Pods.add({ url: pod.url, publicKey: body.cert, score: constants.FRIEND_BASE_SCORE }, function (err, podCreated) {
+ if (err) logger.error('Cannot add friend %s pod.', pod.url)