aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/v1/pods.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/v1/pods.js')
-rw-r--r--server/controllers/api/v1/pods.js17
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
3const async = require('async') 3const async = require('async')
4const express = require('express') 4const express = require('express')
5const mongoose = require('mongoose')
5 6
6const logger = require('../../../helpers/logger') 7const logger = require('../../../helpers/logger')
7const friends = require('../../../lib/friends') 8const friends = require('../../../lib/friends')
@@ -10,10 +11,9 @@ const Pods = require('../../../models/pods')
10const oAuth2 = middlewares.oauth2 11const oAuth2 = middlewares.oauth2
11const reqValidator = middlewares.reqValidators.pods 12const reqValidator = middlewares.reqValidators.pods
12const signatureValidator = middlewares.reqValidators.remote.signature 13const signatureValidator = middlewares.reqValidators.remote.signature
13const videos = require('../../../lib/videos')
14const Videos = require('../../../models/videos')
15 14
16const router = express.Router() 15const router = express.Router()
16const Video = mongoose.model('Video')
17 17
18router.get('/', listPodsUrl) 18router.get('/', listPodsUrl)
19router.post('/', reqValidator.podsAdd, addPods) 19router.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)