diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-01-30 17:05:22 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-01-30 17:05:22 +0100 |
commit | cda021079ff455cc0fd0eb95a5395fa808ab63d1 (patch) | |
tree | 056716de7460462b74b861051a5e9da6e2633fce /controllers/api/v1/remoteVideos.js | |
parent | 86435b9baedfe300a28ea4545511c1b50d4119f6 (diff) | |
download | PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.gz PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.tar.zst PeerTube-cda021079ff455cc0fd0eb95a5395fa808ab63d1.zip |
New directory organization
Diffstat (limited to 'controllers/api/v1/remoteVideos.js')
-rw-r--r-- | controllers/api/v1/remoteVideos.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/controllers/api/v1/remoteVideos.js b/controllers/api/v1/remoteVideos.js new file mode 100644 index 000000000..d534d6792 --- /dev/null +++ b/controllers/api/v1/remoteVideos.js | |||
@@ -0,0 +1,33 @@ | |||
1 | ;(function () { | ||
2 | 'use strict' | ||
3 | |||
4 | var express = require('express') | ||
5 | var router = express.Router() | ||
6 | var pluck = require('lodash-node/compat/collection/pluck') | ||
7 | |||
8 | var middleware = require('../../../middlewares') | ||
9 | var miscMiddleware = middleware.misc | ||
10 | var reqValidator = middleware.reqValidators.remote | ||
11 | var videos = require('../../../models/videos') | ||
12 | |||
13 | function addRemoteVideos (req, res, next) { | ||
14 | videos.addRemotes(req.body.data, function (err, videos) { | ||
15 | if (err) return next(err) | ||
16 | |||
17 | res.json(videos) | ||
18 | }) | ||
19 | } | ||
20 | |||
21 | function removeRemoteVideo (req, res, next) { | ||
22 | videos.removeRemotes(req.body.signature.url, pluck(req.body.data, 'magnetUri'), function (err) { | ||
23 | if (err) return next(err) | ||
24 | |||
25 | res.sendStatus(204) | ||
26 | }) | ||
27 | } | ||
28 | |||
29 | router.post('/add', reqValidator.secureRequest, miscMiddleware.decryptBody, reqValidator.remoteVideosAdd, miscMiddleware.cache(false), addRemoteVideos) | ||
30 | router.post('/remove', reqValidator.secureRequest, miscMiddleware.decryptBody, reqValidator.remoteVideosRemove, miscMiddleware.cache(false), removeRemoteVideo) | ||
31 | |||
32 | module.exports = router | ||
33 | })() | ||