aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/pods.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/pods.js')
-rw-r--r--server/controllers/api/pods.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/server/controllers/api/pods.js b/server/controllers/api/pods.js
index 7857fcee0..79f3f9d8d 100644
--- a/server/controllers/api/pods.js
+++ b/server/controllers/api/pods.js
@@ -1,9 +1,9 @@
1'use strict' 1'use strict'
2 2
3const express = require('express') 3const express = require('express')
4const mongoose = require('mongoose')
5const waterfall = require('async/waterfall') 4const waterfall = require('async/waterfall')
6 5
6const db = require('../../initializers/database')
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')
@@ -15,7 +15,6 @@ const validators = middlewares.validators.pods
15const signatureValidator = middlewares.validators.remote.signature 15const signatureValidator = middlewares.validators.remote.signature
16 16
17const router = express.Router() 17const router = express.Router()
18const Pod = mongoose.model('Pod')
19 18
20router.get('/', listPods) 19router.get('/', listPods)
21router.post('/', 20router.post('/',
@@ -53,15 +52,15 @@ function addPods (req, res, next) {
53 52
54 waterfall([ 53 waterfall([
55 function addPod (callback) { 54 function addPod (callback) {
56 const pod = new Pod(informations) 55 const pod = db.Pod.build(informations)
57 pod.save(function (err, podCreated) { 56 pod.save().asCallback(function (err, podCreated) {
58 // Be sure about the number of parameters for the callback 57 // Be sure about the number of parameters for the callback
59 return callback(err, podCreated) 58 return callback(err, podCreated)
60 }) 59 })
61 }, 60 },
62 61
63 function sendMyVideos (podCreated, callback) { 62 function sendMyVideos (podCreated, callback) {
64 friends.sendOwnedVideosToPod(podCreated._id) 63 friends.sendOwnedVideosToPod(podCreated.id)
65 64
66 callback(null) 65 callback(null)
67 }, 66 },
@@ -84,7 +83,7 @@ function addPods (req, res, next) {
84} 83}
85 84
86function listPods (req, res, next) { 85function listPods (req, res, next) {
87 Pod.list(function (err, podsList) { 86 db.Pod.list(function (err, podsList) {
88 if (err) return next(err) 87 if (err) return next(err)
89 88
90 res.json(getFormatedPods(podsList)) 89 res.json(getFormatedPods(podsList))
@@ -111,11 +110,11 @@ function removePods (req, res, next) {
111 110
112 waterfall([ 111 waterfall([
113 function loadPod (callback) { 112 function loadPod (callback) {
114 Pod.loadByHost(host, callback) 113 db.Pod.loadByHost(host, callback)
115 }, 114 },
116 115
117 function removePod (pod, callback) { 116 function removePod (pod, callback) {
118 pod.remove(callback) 117 pod.destroy().asCallback(callback)
119 } 118 }
120 ], function (err) { 119 ], function (err) {
121 if (err) return next(err) 120 if (err) return next(err)