]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/controllers/api/v1/remoteVideos.js
5e9e71fdd4386fd48dd7137c81b078169c07494e
3 const express
= require('express')
4 const map
= require('lodash/map')
6 const middleware
= require('../../../middlewares')
7 const secureMiddleware
= middleware
.secure
8 const cacheMiddleware
= middleware
.cache
9 const reqValidator
= middleware
.reqValidators
.remote
10 const videos
= require('../../../models/videos')
12 const router
= express
.Router()
15 reqValidator
.secureRequest
,
16 secureMiddleware
.decryptBody
,
17 reqValidator
.remoteVideosAdd
,
18 cacheMiddleware
.cache(false),
22 router
.post('/remove',
23 reqValidator
.secureRequest
,
24 secureMiddleware
.decryptBody
,
25 reqValidator
.remoteVideosRemove
,
26 cacheMiddleware
.cache(false),
30 // ---------------------------------------------------------------------------
32 module
.exports
= router
34 // ---------------------------------------------------------------------------
36 function addRemoteVideos (req
, res
, next
) {
37 videos
.addRemotes(req
.body
.data
, function (err
, videos
) {
38 if (err
) return next(err
)
44 function removeRemoteVideo (req
, res
, next
) {
45 const url
= req
.body
.signature
.url
46 const magnetUris
= map(req
.body
.data
, 'magnetUri')
48 videos
.removeRemotesOfByMagnetUris(url
, magnetUris
, function (err
) {
49 if (err
) return next(err
)
51 res
.type('json').status(204).end()