diff options
Diffstat (limited to 'server/controllers/api/v1/pods.js')
-rw-r--r-- | server/controllers/api/v1/pods.js | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js index 881b2090d..9dd9197b3 100644 --- a/server/controllers/api/v1/pods.js +++ b/server/controllers/api/v1/pods.js | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | const async = require('async') | 3 | const async = require('async') |
4 | const express = require('express') | 4 | const express = require('express') |
5 | const mongoose = require('mongoose') | ||
5 | 6 | ||
6 | const logger = require('../../../helpers/logger') | 7 | const logger = require('../../../helpers/logger') |
7 | const friends = require('../../../lib/friends') | 8 | const friends = require('../../../lib/friends') |
@@ -10,10 +11,9 @@ const Pods = require('../../../models/pods') | |||
10 | const oAuth2 = middlewares.oauth2 | 11 | const oAuth2 = middlewares.oauth2 |
11 | const reqValidator = middlewares.reqValidators.pods | 12 | const reqValidator = middlewares.reqValidators.pods |
12 | const signatureValidator = middlewares.reqValidators.remote.signature | 13 | const signatureValidator = middlewares.reqValidators.remote.signature |
13 | const videos = require('../../../lib/videos') | ||
14 | const Videos = require('../../../models/videos') | ||
15 | 14 | ||
16 | const router = express.Router() | 15 | const router = express.Router() |
16 | const Video = mongoose.model('Video') | ||
17 | 17 | ||
18 | router.get('/', listPodsUrl) | 18 | router.get('/', listPodsUrl) |
19 | router.post('/', reqValidator.podsAdd, addPods) | 19 | router.post('/', reqValidator.podsAdd, addPods) |
@@ -86,7 +86,7 @@ function removePods (req, res, next) { | |||
86 | }, | 86 | }, |
87 | 87 | ||
88 | function (callback) { | 88 | function (callback) { |
89 | Videos.listFromUrl(url, function (err, videosList) { | 89 | Video.listByUrls([ url ], function (err, videosList) { |
90 | if (err) { | 90 | if (err) { |
91 | logger.error('Cannot list videos from url.', { error: err }) | 91 | logger.error('Cannot list videos from url.', { error: err }) |
92 | return callback(err) | 92 | return callback(err) |
@@ -97,14 +97,9 @@ function removePods (req, res, next) { | |||
97 | }, | 97 | }, |
98 | 98 | ||
99 | function removeTheRemoteVideos (videosList, callback) { | 99 | function removeTheRemoteVideos (videosList, callback) { |
100 | videos.removeRemoteVideos(videosList, function (err) { | 100 | async.each(videosList, function (video, callbackEach) { |
101 | if (err) { | 101 | video.remove(callbackEach) |
102 | logger.error('Cannot remove remote videos.', { error: err }) | 102 | }, callback) |
103 | return callback(err) | ||
104 | } | ||
105 | |||
106 | return callback(null) | ||
107 | }) | ||
108 | } | 103 | } |
109 | ], function (err) { | 104 | ], function (err) { |
110 | if (err) return next(err) | 105 | if (err) return next(err) |