diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-03-07 11:33:59 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-03-07 11:33:59 +0100 |
commit | b9a3e09ad5a7673f64556d1dba122ed4c4fac980 (patch) | |
tree | 66d4928b82af19a2372a2505822233884f3fd471 /server/controllers/api/v1/remoteVideos.js | |
parent | b2ff5e3e686eb552c5ccd64ce67b0455972ceef0 (diff) | |
download | PeerTube-b9a3e09ad5a7673f64556d1dba122ed4c4fac980.tar.gz PeerTube-b9a3e09ad5a7673f64556d1dba122ed4c4fac980.tar.zst PeerTube-b9a3e09ad5a7673f64556d1dba122ed4c4fac980.zip |
Prepare folders structure for angular app
Diffstat (limited to 'server/controllers/api/v1/remoteVideos.js')
-rw-r--r-- | server/controllers/api/v1/remoteVideos.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/server/controllers/api/v1/remoteVideos.js b/server/controllers/api/v1/remoteVideos.js new file mode 100644 index 000000000..475a874cf --- /dev/null +++ b/server/controllers/api/v1/remoteVideos.js | |||
@@ -0,0 +1,53 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | var express = require('express') | ||
4 | var pluck = require('lodash-node/compat/collection/pluck') | ||
5 | |||
6 | var middleware = require('../../../middlewares') | ||
7 | var secureMiddleware = middleware.secure | ||
8 | var cacheMiddleware = middleware.cache | ||
9 | var reqValidator = middleware.reqValidators.remote | ||
10 | var videos = require('../../../models/videos') | ||
11 | |||
12 | var router = express.Router() | ||
13 | |||
14 | router.post('/add', | ||
15 | reqValidator.secureRequest, | ||
16 | secureMiddleware.decryptBody, | ||
17 | reqValidator.remoteVideosAdd, | ||
18 | cacheMiddleware.cache(false), | ||
19 | addRemoteVideos | ||
20 | ) | ||
21 | |||
22 | router.post('/remove', | ||
23 | reqValidator.secureRequest, | ||
24 | secureMiddleware.decryptBody, | ||
25 | reqValidator.remoteVideosRemove, | ||
26 | cacheMiddleware.cache(false), | ||
27 | removeRemoteVideo | ||
28 | ) | ||
29 | |||
30 | // --------------------------------------------------------------------------- | ||
31 | |||
32 | module.exports = router | ||
33 | |||
34 | // --------------------------------------------------------------------------- | ||
35 | |||
36 | function addRemoteVideos (req, res, next) { | ||
37 | videos.addRemotes(req.body.data, function (err, videos) { | ||
38 | if (err) return next(err) | ||
39 | |||
40 | res.json(videos) | ||
41 | }) | ||
42 | } | ||
43 | |||
44 | function removeRemoteVideo (req, res, next) { | ||
45 | var url = req.body.signature.url | ||
46 | var magnetUris = pluck(req.body.data, 'magnetUri') | ||
47 | |||
48 | videos.removeRemotesOfByMagnetUris(url, magnetUris, function (err) { | ||
49 | if (err) return next(err) | ||
50 | |||
51 | res.sendStatus(204) | ||
52 | }) | ||
53 | } | ||