aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/remote
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/remote')
-rw-r--r--server/controllers/api/remote/index.js2
-rw-r--r--server/controllers/api/remote/pods.js42
2 files changed, 44 insertions, 0 deletions
diff --git a/server/controllers/api/remote/index.js b/server/controllers/api/remote/index.js
index 2947632d5..6106850ab 100644
--- a/server/controllers/api/remote/index.js
+++ b/server/controllers/api/remote/index.js
@@ -6,8 +6,10 @@ const utils = require('../../../helpers/utils')
6 6
7const router = express.Router() 7const router = express.Router()
8 8
9const podsRemoteController = require('./pods')
9const videosRemoteController = require('./videos') 10const videosRemoteController = require('./videos')
10 11
12router.use('/pods', podsRemoteController)
11router.use('/videos', videosRemoteController) 13router.use('/videos', videosRemoteController)
12router.use('/*', utils.badRequest) 14router.use('/*', utils.badRequest)
13 15
diff --git a/server/controllers/api/remote/pods.js b/server/controllers/api/remote/pods.js
new file mode 100644
index 000000000..0343bc62e
--- /dev/null
+++ b/server/controllers/api/remote/pods.js
@@ -0,0 +1,42 @@
1'use strict'
2
3const express = require('express')
4const waterfall = require('async/waterfall')
5
6const db = require('../../../initializers/database')
7const middlewares = require('../../../middlewares')
8const checkSignature = middlewares.secure.checkSignature
9const signatureValidator = middlewares.validators.remote.signature
10
11const router = express.Router()
12
13// Post because this is a secured request
14router.post('/remove',
15 signatureValidator.signature,
16 checkSignature,
17 removePods
18)
19
20// ---------------------------------------------------------------------------
21
22module.exports = router
23
24// ---------------------------------------------------------------------------
25
26function removePods (req, res, next) {
27 const host = req.body.signature.host
28
29 waterfall([
30 function loadPod (callback) {
31 db.Pod.loadByHost(host, callback)
32 },
33
34 function deletePod (pod, callback) {
35 pod.destroy().asCallback(callback)
36 }
37 ], function (err) {
38 if (err) return next(err)
39
40 return res.type('json').status(204).end()
41 })
42}