aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-06-30 22:39:08 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-06-30 22:39:08 +0200
commita3ee6fa22dee4b68fcde9cd23708b471db446e11 (patch)
treeb05543f6d858c52dd4757123bc605277ede96983 /server/controllers/api
parentd14b3e37a2c0d647b59259bf2ca059b5817f144c (diff)
downloadPeerTube-a3ee6fa22dee4b68fcde9cd23708b471db446e11.tar.gz
PeerTube-a3ee6fa22dee4b68fcde9cd23708b471db446e11.tar.zst
PeerTube-a3ee6fa22dee4b68fcde9cd23708b471db446e11.zip
Pod model refractoring -> use mongoose api
Diffstat (limited to 'server/controllers/api')
-rw-r--r--server/controllers/api/v1/pods.js19
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')
7const logger = require('../../../helpers/logger') 7const logger = require('../../../helpers/logger')
8const friends = require('../../../lib/friends') 8const friends = require('../../../lib/friends')
9const middlewares = require('../../../middlewares') 9const middlewares = require('../../../middlewares')
10const Pods = require('../../../models/pods')
11const oAuth2 = middlewares.oauth2 10const oAuth2 = middlewares.oauth2
12const reqValidator = middlewares.reqValidators.pods 11const reqValidator = middlewares.reqValidators.pods
13const signatureValidator = middlewares.reqValidators.remote.signature 12const signatureValidator = middlewares.reqValidators.remote.signature
14 13
15const router = express.Router() 14const router = express.Router()
15const Pod = mongoose.model('Pod')
16const Video = mongoose.model('Video') 16const Video = mongoose.model('Video')
17 17
18router.get('/', listPodsUrl) 18router.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
62function listPodsUrl (req, res, next) { 66function 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 },