diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-06-18 16:13:54 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-06-18 16:13:54 +0200 |
commit | 528a9efa8272532bbd0dafc35c3e05e57c50f61e (patch) | |
tree | 62d4417df4ab9b2e53c44dc7271be81b88e4e0e5 /server/controllers/api/v1/remoteVideos.js | |
parent | b2e4c0ba1a33b8a50491a1f8d111468a7da5640f (diff) | |
download | PeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.tar.gz PeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.tar.zst PeerTube-528a9efa8272532bbd0dafc35c3e05e57c50f61e.zip |
Try to make a better communication (between pods) module
Diffstat (limited to 'server/controllers/api/v1/remoteVideos.js')
-rw-r--r-- | server/controllers/api/v1/remoteVideos.js | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/server/controllers/api/v1/remoteVideos.js b/server/controllers/api/v1/remoteVideos.js deleted file mode 100644 index 2f41c0411..000000000 --- a/server/controllers/api/v1/remoteVideos.js +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const express = require('express') | ||
4 | const map = require('lodash/map') | ||
5 | |||
6 | const middlewares = require('../../../middlewares') | ||
7 | const secureMiddleware = middlewares.secure | ||
8 | const reqValidator = middlewares.reqValidators.remote | ||
9 | const logger = require('../../../helpers/logger') | ||
10 | const Videos = require('../../../models/videos') | ||
11 | const videos = require('../../../lib/videos') | ||
12 | |||
13 | const router = express.Router() | ||
14 | |||
15 | router.post('/add', | ||
16 | reqValidator.secureRequest, | ||
17 | secureMiddleware.decryptBody, | ||
18 | reqValidator.remoteVideosAdd, | ||
19 | addRemoteVideos | ||
20 | ) | ||
21 | |||
22 | router.post('/remove', | ||
23 | reqValidator.secureRequest, | ||
24 | secureMiddleware.decryptBody, | ||
25 | reqValidator.remoteVideosRemove, | ||
26 | removeRemoteVideo | ||
27 | ) | ||
28 | |||
29 | // --------------------------------------------------------------------------- | ||
30 | |||
31 | module.exports = router | ||
32 | |||
33 | // --------------------------------------------------------------------------- | ||
34 | |||
35 | function addRemoteVideos (req, res, next) { | ||
36 | const videosToCreate = req.body.data | ||
37 | videos.createRemoteVideos(videosToCreate, function (err, remoteVideos) { | ||
38 | if (err) { | ||
39 | logger.error('Cannot create remote videos.', { error: err }) | ||
40 | return next(err) | ||
41 | } | ||
42 | |||
43 | res.type('json').status(201).end() | ||
44 | }) | ||
45 | } | ||
46 | |||
47 | function removeRemoteVideo (req, res, next) { | ||
48 | const fromUrl = req.body.signature.url | ||
49 | const magnetUris = map(req.body.data, 'magnetUri') | ||
50 | |||
51 | Videos.listFromUrlAndMagnets(fromUrl, magnetUris, function (err, videosList) { | ||
52 | if (err) { | ||
53 | logger.error('Cannot list videos from url and magnets.', { error: err }) | ||
54 | return next(err) | ||
55 | } | ||
56 | |||
57 | videos.removeRemoteVideos(videosList, function (err) { | ||
58 | if (err) { | ||
59 | logger.error('Cannot remove remote videos.', { error: err }) | ||
60 | return next(err) | ||
61 | } | ||
62 | |||
63 | res.type('json').status(204).end() | ||
64 | }) | ||
65 | }) | ||
66 | } | ||