aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/v1/remoteVideos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-06-18 16:13:54 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-06-18 16:13:54 +0200
commit528a9efa8272532bbd0dafc35c3e05e57c50f61e (patch)
tree62d4417df4ab9b2e53c44dc7271be81b88e4e0e5 /server/controllers/api/v1/remoteVideos.js
parentb2e4c0ba1a33b8a50491a1f8d111468a7da5640f (diff)
downloadPeerTube-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.js66
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
3const express = require('express')
4const map = require('lodash/map')
5
6const middlewares = require('../../../middlewares')
7const secureMiddleware = middlewares.secure
8const reqValidator = middlewares.reqValidators.remote
9const logger = require('../../../helpers/logger')
10const Videos = require('../../../models/videos')
11const videos = require('../../../lib/videos')
12
13const router = express.Router()
14
15router.post('/add',
16 reqValidator.secureRequest,
17 secureMiddleware.decryptBody,
18 reqValidator.remoteVideosAdd,
19 addRemoteVideos
20)
21
22router.post('/remove',
23 reqValidator.secureRequest,
24 secureMiddleware.decryptBody,
25 reqValidator.remoteVideosRemove,
26 removeRemoteVideo
27)
28
29// ---------------------------------------------------------------------------
30
31module.exports = router
32
33// ---------------------------------------------------------------------------
34
35function 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
47function 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}