From 49abbbbedca83b9031d3e2eb3ae9ad9b6a7d96ed Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Nov 2016 20:03:04 +0100 Subject: Pod URL -> pod host. HTTPS is required to make friends. Reason: in a network with mix http/https pods, https pods won't be able to play videos from http pod (insecure requests). --- server/controllers/api/pods.js | 16 ++++++++-------- server/controllers/api/remote.js | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/pods.js b/server/controllers/api/pods.js index 853e0705b..7857fcee0 100644 --- a/server/controllers/api/pods.js +++ b/server/controllers/api/pods.js @@ -20,14 +20,14 @@ const Pod = mongoose.model('Pod') router.get('/', listPods) router.post('/', validators.podsAdd, - podsMiddleware.setBodyUrlPort, + podsMiddleware.setBodyHostPort, addPods ) router.post('/makefriends', oAuth.authenticate, admin.ensureIsAdmin, validators.makeFriends, - podsMiddleware.setBodyUrlsPort, + podsMiddleware.setBodyHostsPort, makeFriends ) router.get('/quitfriends', @@ -84,17 +84,17 @@ function addPods (req, res, next) { } function listPods (req, res, next) { - Pod.list(function (err, podsUrlList) { + Pod.list(function (err, podsList) { if (err) return next(err) - res.json(getFormatedPods(podsUrlList)) + res.json(getFormatedPods(podsList)) }) } function makeFriends (req, res, next) { - const urls = req.body.urls + const hosts = req.body.hosts - friends.makeFriends(urls, function (err) { + friends.makeFriends(hosts, function (err) { if (err) { logger.error('Could not make friends.', { error: err }) return @@ -107,11 +107,11 @@ function makeFriends (req, res, next) { } function removePods (req, res, next) { - const url = req.body.signature.url + const host = req.body.signature.host waterfall([ function loadPod (callback) { - Pod.loadByUrl(url, callback) + Pod.loadByHost(host, callback) }, function removePod (pod, callback) { diff --git a/server/controllers/api/remote.js b/server/controllers/api/remote.js index 94808693d..4085deb2d 100644 --- a/server/controllers/api/remote.js +++ b/server/controllers/api/remote.js @@ -30,7 +30,7 @@ module.exports = router function remoteVideos (req, res, next) { const requests = req.body.data - const fromUrl = req.body.signature.url + const fromHost = req.body.signature.host // We need to process in the same order to keep consistency // TODO: optimization @@ -40,7 +40,7 @@ function remoteVideos (req, res, next) { if (request.type === 'add') { addRemoteVideo(videoData, callbackEach) } else if (request.type === 'remove') { - removeRemoteVideo(videoData, fromUrl, callbackEach) + removeRemoteVideo(videoData, fromHost, callbackEach) } else { logger.error('Unkown remote request type %s.', request.type) } @@ -62,16 +62,16 @@ function addRemoteVideo (videoToCreateData, callback) { video.save(callback) } -function removeRemoteVideo (videoToRemoveData, fromUrl, callback) { +function removeRemoteVideo (videoToRemoveData, fromHost, callback) { // We need the list because we have to remove some other stuffs (thumbnail etc) - Video.listByUrlAndRemoteId(fromUrl, videoToRemoveData.remoteId, function (err, videosList) { + Video.listByHostAndRemoteId(fromHost, videoToRemoveData.remoteId, function (err, videosList) { if (err) { - logger.error('Cannot list videos from url and magnets.', { error: err }) + logger.error('Cannot list videos from host and magnets.', { error: err }) return callback(err) } if (videosList.length === 0) { - logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl }) + logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podHost: fromHost }) } each(videosList, function (video, callbackEach) { -- cgit v1.2.3