]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - controllers/api/v1/remoteVideos.js
4 var express
= require('express')
5 var pluck
= require('lodash-node/compat/collection/pluck')
7 var middleware
= require('../../../middlewares')
8 var secureMiddleware
= middleware
.secure
9 var cacheMiddleware
= middleware
.cache
10 var reqValidator
= middleware
.reqValidators
.remote
11 var videos
= require('../../../models/videos')
13 var router
= express
.Router()
16 reqValidator
.secureRequest
,
17 secureMiddleware
.decryptBody
,
18 reqValidator
.remoteVideosAdd
,
19 cacheMiddleware
.cache(false),
23 router
.post('/remove',
24 reqValidator
.secureRequest
,
25 secureMiddleware
.decryptBody
,
26 reqValidator
.remoteVideosRemove
,
27 cacheMiddleware
.cache(false),
31 // ---------------------------------------------------------------------------
33 module
.exports
= router
35 // ---------------------------------------------------------------------------
37 function addRemoteVideos (req
, res
, next
) {
38 videos
.addRemotes(req
.body
.data
, function (err
, videos
) {
39 if (err
) return next(err
)
45 function removeRemoteVideo (req
, res
, next
) {
46 var url
= req
.body
.signature
.url
47 var magnetUris
= pluck(req
.body
.data
, 'magnetUri')
49 videos
.removeRemotesOfByMagnetUris(url
, magnetUris
, function (err
) {
50 if (err
) return next(err
)