diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/v1/pods.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js index 9dd9197b3..feb6bd958 100644 --- a/server/controllers/api/v1/pods.js +++ b/server/controllers/api/v1/pods.js | |||
@@ -7,12 +7,12 @@ const mongoose = require('mongoose') | |||
7 | const logger = require('../../../helpers/logger') | 7 | const logger = require('../../../helpers/logger') |
8 | const friends = require('../../../lib/friends') | 8 | const friends = require('../../../lib/friends') |
9 | const middlewares = require('../../../middlewares') | 9 | const middlewares = require('../../../middlewares') |
10 | const Pods = require('../../../models/pods') | ||
11 | const oAuth2 = middlewares.oauth2 | 10 | const oAuth2 = middlewares.oauth2 |
12 | const reqValidator = middlewares.reqValidators.pods | 11 | const reqValidator = middlewares.reqValidators.pods |
13 | const signatureValidator = middlewares.reqValidators.remote.signature | 12 | const signatureValidator = middlewares.reqValidators.remote.signature |
14 | 13 | ||
15 | const router = express.Router() | 14 | const router = express.Router() |
15 | const Pod = mongoose.model('Pod') | ||
16 | const Video = mongoose.model('Video') | 16 | const Video = mongoose.model('Video') |
17 | 17 | ||
18 | router.get('/', listPodsUrl) | 18 | router.get('/', listPodsUrl) |
@@ -33,7 +33,11 @@ function addPods (req, res, next) { | |||
33 | 33 | ||
34 | async.waterfall([ | 34 | async.waterfall([ |
35 | function addPod (callback) { | 35 | function addPod (callback) { |
36 | Pods.add(informations, callback) | 36 | const pod = new Pod(informations) |
37 | pod.save(function (err, podCreated) { | ||
38 | // Be sure about the number of parameters for the callback | ||
39 | return callback(err, podCreated) | ||
40 | }) | ||
37 | }, | 41 | }, |
38 | 42 | ||
39 | function sendMyVideos (podCreated, callback) { | 43 | function sendMyVideos (podCreated, callback) { |
@@ -60,7 +64,7 @@ function addPods (req, res, next) { | |||
60 | } | 64 | } |
61 | 65 | ||
62 | function listPodsUrl (req, res, next) { | 66 | function listPodsUrl (req, res, next) { |
63 | Pods.listAllUrls(function (err, podsUrlList) { | 67 | Pod.listOnlyUrls(function (err, podsUrlList) { |
64 | if (err) return next(err) | 68 | if (err) return next(err) |
65 | 69 | ||
66 | res.json(podsUrlList) | 70 | res.json(podsUrlList) |
@@ -79,8 +83,13 @@ function removePods (req, res, next) { | |||
79 | const url = req.body.signature.url | 83 | const url = req.body.signature.url |
80 | 84 | ||
81 | async.waterfall([ | 85 | async.waterfall([ |
82 | function (callback) { | 86 | function loadPod (callback) { |
83 | Pods.remove(url, function (err) { | 87 | Pod.loadByUrl(url, callback) |
88 | }, | ||
89 | |||
90 | function removePod (pod, callback) { | ||
91 | pod.remove(function (err) { | ||
92 | // Be sure we only return one argument in the callback | ||
84 | return callback(err) | 93 | return callback(err) |
85 | }) | 94 | }) |
86 | }, | 95 | }, |