diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-12-11 21:50:51 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-12-19 21:22:28 +0100 |
commit | feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c (patch) | |
tree | 2abc9fbc9569760e218fd52835850b757344b420 /server/controllers/api/pods.js | |
parent | 108626609eda75e4ecc0a83a650a4d53c46220e0 (diff) | |
download | PeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.tar.gz PeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.tar.zst PeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.zip |
First version with PostgreSQL
Diffstat (limited to 'server/controllers/api/pods.js')
-rw-r--r-- | server/controllers/api/pods.js | 15 |
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 | ||
3 | const express = require('express') | 3 | const express = require('express') |
4 | const mongoose = require('mongoose') | ||
5 | const waterfall = require('async/waterfall') | 4 | const waterfall = require('async/waterfall') |
6 | 5 | ||
6 | const db = require('../../initializers/database') | ||
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') |
@@ -15,7 +15,6 @@ const validators = middlewares.validators.pods | |||
15 | const signatureValidator = middlewares.validators.remote.signature | 15 | const signatureValidator = middlewares.validators.remote.signature |
16 | 16 | ||
17 | const router = express.Router() | 17 | const router = express.Router() |
18 | const Pod = mongoose.model('Pod') | ||
19 | 18 | ||
20 | router.get('/', listPods) | 19 | router.get('/', listPods) |
21 | router.post('/', | 20 | router.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 | ||
86 | function listPods (req, res, next) { | 85 | function 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) |