aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/api/v1
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2015-12-04 16:13:32 +0100
committerChocobozzz <florian.bigard@gmail.com>2015-12-04 16:13:32 +0100
commit0b69752270f1ceea06a29872b3db23660a55d6d3 (patch)
tree42da726633f3e48f4fe592cfd2c1ca14346a159b /routes/api/v1
parentaf82cae07dc568e3cb10acd70113df56eb8b15a9 (diff)
downloadPeerTube-0b69752270f1ceea06a29872b3db23660a55d6d3.tar.gz
PeerTube-0b69752270f1ceea06a29872b3db23660a55d6d3.tar.zst
PeerTube-0b69752270f1ceea06a29872b3db23660a55d6d3.zip
Add a pool of requests instead of making a request at each action (add
video/remove video) for performance in big networks
Diffstat (limited to 'routes/api/v1')
-rw-r--r--routes/api/v1/remoteVideos.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/routes/api/v1/remoteVideos.js b/routes/api/v1/remoteVideos.js
index 10793b2b4..a104113b2 100644
--- a/routes/api/v1/remoteVideos.js
+++ b/routes/api/v1/remoteVideos.js
@@ -3,21 +3,23 @@
3 3
4 var express = require('express') 4 var express = require('express')
5 var router = express.Router() 5 var router = express.Router()
6 var pluck = require('lodash-node/compat/collection/pluck')
7
6 var middleware = require('../../../middlewares') 8 var middleware = require('../../../middlewares')
7 var miscMiddleware = middleware.misc 9 var miscMiddleware = middleware.misc
8 var reqValidator = middleware.reqValidators.remote 10 var reqValidator = middleware.reqValidators.remote
9 var videos = require('../../../src/videos') 11 var videos = require('../../../src/videos')
10 12
11 function addRemoteVideos (req, res, next) { 13 function addRemoteVideos (req, res, next) {
12 videos.addRemote(req.body.data, function (err, video) { 14 videos.addRemotes(req.body.data, function (err, videos) {
13 if (err) return next(err) 15 if (err) return next(err)
14 16
15 res.json(video) 17 res.json(videos)
16 }) 18 })
17 } 19 }
18 20
19 function removeRemoteVideo (req, res, next) { 21 function removeRemoteVideo (req, res, next) {
20 videos.removeRemote(req.body.signature.url, req.body.data.magnetUri, function (err) { 22 videos.removeRemotes(req.body.signature.url, pluck(req.body.data, 'magnetUri'), function (err) {
21 if (err) return next(err) 23 if (err) return next(err)
22 24
23 res.status(204) 25 res.status(204)