aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/pods.js16
-rw-r--r--server/controllers/api/remote.js12
2 files changed, 14 insertions, 14 deletions
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')
20router.get('/', listPods) 20router.get('/', listPods)
21router.post('/', 21router.post('/',
22 validators.podsAdd, 22 validators.podsAdd,
23 podsMiddleware.setBodyUrlPort, 23 podsMiddleware.setBodyHostPort,
24 addPods 24 addPods
25) 25)
26router.post('/makefriends', 26router.post('/makefriends',
27 oAuth.authenticate, 27 oAuth.authenticate,
28 admin.ensureIsAdmin, 28 admin.ensureIsAdmin,
29 validators.makeFriends, 29 validators.makeFriends,
30 podsMiddleware.setBodyUrlsPort, 30 podsMiddleware.setBodyHostsPort,
31 makeFriends 31 makeFriends
32) 32)
33router.get('/quitfriends', 33router.get('/quitfriends',
@@ -84,17 +84,17 @@ function addPods (req, res, next) {
84} 84}
85 85
86function listPods (req, res, next) { 86function listPods (req, res, next) {
87 Pod.list(function (err, podsUrlList) { 87 Pod.list(function (err, podsList) {
88 if (err) return next(err) 88 if (err) return next(err)
89 89
90 res.json(getFormatedPods(podsUrlList)) 90 res.json(getFormatedPods(podsList))
91 }) 91 })
92} 92}
93 93
94function makeFriends (req, res, next) { 94function makeFriends (req, res, next) {
95 const urls = req.body.urls 95 const hosts = req.body.hosts
96 96
97 friends.makeFriends(urls, function (err) { 97 friends.makeFriends(hosts, function (err) {
98 if (err) { 98 if (err) {
99 logger.error('Could not make friends.', { error: err }) 99 logger.error('Could not make friends.', { error: err })
100 return 100 return
@@ -107,11 +107,11 @@ function makeFriends (req, res, next) {
107} 107}
108 108
109function removePods (req, res, next) { 109function removePods (req, res, next) {
110 const url = req.body.signature.url 110 const host = req.body.signature.host
111 111
112 waterfall([ 112 waterfall([
113 function loadPod (callback) { 113 function loadPod (callback) {
114 Pod.loadByUrl(url, callback) 114 Pod.loadByHost(host, callback)
115 }, 115 },
116 116
117 function removePod (pod, callback) { 117 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
30 30
31function remoteVideos (req, res, next) { 31function remoteVideos (req, res, next) {
32 const requests = req.body.data 32 const requests = req.body.data
33 const fromUrl = req.body.signature.url 33 const fromHost = req.body.signature.host
34 34
35 // We need to process in the same order to keep consistency 35 // We need to process in the same order to keep consistency
36 // TODO: optimization 36 // TODO: optimization
@@ -40,7 +40,7 @@ function remoteVideos (req, res, next) {
40 if (request.type === 'add') { 40 if (request.type === 'add') {
41 addRemoteVideo(videoData, callbackEach) 41 addRemoteVideo(videoData, callbackEach)
42 } else if (request.type === 'remove') { 42 } else if (request.type === 'remove') {
43 removeRemoteVideo(videoData, fromUrl, callbackEach) 43 removeRemoteVideo(videoData, fromHost, callbackEach)
44 } else { 44 } else {
45 logger.error('Unkown remote request type %s.', request.type) 45 logger.error('Unkown remote request type %s.', request.type)
46 } 46 }
@@ -62,16 +62,16 @@ function addRemoteVideo (videoToCreateData, callback) {
62 video.save(callback) 62 video.save(callback)
63} 63}
64 64
65function removeRemoteVideo (videoToRemoveData, fromUrl, callback) { 65function removeRemoteVideo (videoToRemoveData, fromHost, callback) {
66 // We need the list because we have to remove some other stuffs (thumbnail etc) 66 // We need the list because we have to remove some other stuffs (thumbnail etc)
67 Video.listByUrlAndRemoteId(fromUrl, videoToRemoveData.remoteId, function (err, videosList) { 67 Video.listByHostAndRemoteId(fromHost, videoToRemoveData.remoteId, function (err, videosList) {
68 if (err) { 68 if (err) {
69 logger.error('Cannot list videos from url and magnets.', { error: err }) 69 logger.error('Cannot list videos from host and magnets.', { error: err })
70 return callback(err) 70 return callback(err)
71 } 71 }
72 72
73 if (videosList.length === 0) { 73 if (videosList.length === 0) {
74 logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl }) 74 logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podHost: fromHost })
75 } 75 }
76 76
77 each(videosList, function (video, callbackEach) { 77 each(videosList, function (video, callbackEach) {