diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-21 11:20:45 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-21 11:20:45 +0200 |
commit | 80a6c9e76fda57f01e37fe4620771ae70738a211 (patch) | |
tree | 7381a94285c11d954efca2be8103c8b86df3e832 /server/controllers/api/v1/pods.js | |
parent | 792b893ed414301c060391ed8a00368d68688236 (diff) | |
download | PeerTube-80a6c9e76fda57f01e37fe4620771ae70738a211.tar.gz PeerTube-80a6c9e76fda57f01e37fe4620771ae70738a211.tar.zst PeerTube-80a6c9e76fda57f01e37fe4620771ae70738a211.zip |
Server: pod removing refractoring
Diffstat (limited to 'server/controllers/api/v1/pods.js')
-rw-r--r-- | server/controllers/api/v1/pods.js | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js index 8ffade578..2f4621327 100644 --- a/server/controllers/api/v1/pods.js +++ b/server/controllers/api/v1/pods.js | |||
@@ -1,6 +1,5 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const each = require('async/each') | ||
4 | const express = require('express') | 3 | const express = require('express') |
5 | const mongoose = require('mongoose') | 4 | const mongoose = require('mongoose') |
6 | const waterfall = require('async/waterfall') | 5 | const waterfall = require('async/waterfall') |
@@ -17,7 +16,6 @@ const signatureValidator = middlewares.validators.remote.signature | |||
17 | 16 | ||
18 | const router = express.Router() | 17 | const router = express.Router() |
19 | const Pod = mongoose.model('Pod') | 18 | const Pod = mongoose.model('Pod') |
20 | const Video = mongoose.model('Video') | ||
21 | 19 | ||
22 | router.get('/', listPods) | 20 | router.get('/', listPods) |
23 | router.post('/', | 21 | router.post('/', |
@@ -117,27 +115,7 @@ function removePods (req, res, next) { | |||
117 | }, | 115 | }, |
118 | 116 | ||
119 | function removePod (pod, callback) { | 117 | function removePod (pod, callback) { |
120 | pod.remove(function (err) { | 118 | pod.remove(callback) |
121 | // Be sure we only return one argument in the callback | ||
122 | return callback(err) | ||
123 | }) | ||
124 | }, | ||
125 | |||
126 | function (callback) { | ||
127 | Video.listByUrls([ url ], function (err, videosList) { | ||
128 | if (err) { | ||
129 | logger.error('Cannot list videos from url.', { error: err }) | ||
130 | return callback(err) | ||
131 | } | ||
132 | |||
133 | return callback(null, videosList) | ||
134 | }) | ||
135 | }, | ||
136 | |||
137 | function removeTheRemoteVideos (videosList, callback) { | ||
138 | each(videosList, function (video, callbackEach) { | ||
139 | video.remove(callbackEach) | ||
140 | }, callback) | ||
141 | } | 119 | } |
142 | ], function (err) { | 120 | ], function (err) { |
143 | if (err) return next(err) | 121 | if (err) return next(err) |