'use strict'
-const config = require('config')
const each = require('async/each')
const eachLimit = require('async/eachLimit')
const eachSeries = require('async/eachSeries')
const Video = mongoose.model('Video')
const friends = {
- addVideoToFriends: addVideoToFriends,
- hasFriends: hasFriends,
- getMyCertificate: getMyCertificate,
- makeFriends: makeFriends,
- quitFriends: quitFriends,
- removeVideoToFriends: removeVideoToFriends,
- sendOwnedVideosToPod: sendOwnedVideosToPod
+ addVideoToFriends,
+ hasFriends,
+ getMyCertificate,
+ makeFriends,
+ quitFriends,
+ removeVideoToFriends,
+ sendOwnedVideosToPod
}
function addVideoToFriends (video) {
fs.readFile(constants.CONFIG.STORAGE.CERT_DIR + 'peertube.pub', 'utf8', callback)
}
-function makeFriends (callback) {
+function makeFriends (urls, callback) {
const podsScore = {}
logger.info('Make friends!')
return callback(err)
}
- const urls = config.get('network.friends')
-
eachSeries(urls, function (url, callbackEach) {
computeForeignPodsList(url, podsScore, callbackEach)
}, function (err) {
request.get(url + path, function (err, response, body) {
if (err) return callback(err)
- callback(null, JSON.parse(body))
+ try {
+ const json = JSON.parse(body)
+ return callback(null, json)
+ } catch (err) {
+ return callback(err)
+ }
})
}