]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/pods.js
Add video category support
[github/Chocobozzz/PeerTube.git] / server / controllers / api / pods.js
index 38702face2c9a0db53354394e438f2909b91c245..ab5763cf6a1f84f96decc08e6f8ec77cae648c53 100644 (file)
@@ -4,23 +4,23 @@ const express = require('express')
 const waterfall = require('async/waterfall')
 
 const db = require('../../initializers/database')
+const constants = require('../../initializers/constants')
 const logger = require('../../helpers/logger')
+const peertubeCrypto = require('../../helpers/peertube-crypto')
 const utils = require('../../helpers/utils')
 const friends = require('../../lib/friends')
 const middlewares = require('../../middlewares')
 const admin = middlewares.admin
 const oAuth = middlewares.oauth
 const podsMiddleware = middlewares.pods
-const checkSignature = middlewares.secure.checkSignature
 const validators = middlewares.validators.pods
-const signatureValidator = middlewares.validators.remote.signature
 
 const router = express.Router()
 
 router.get('/', listPods)
 router.post('/',
+  podsMiddleware.setBodyHostPort, // We need to modify the host before running the validator!
   validators.podsAdd,
-  podsMiddleware.setBodyHostPort,
   addPods
 )
 router.post('/makefriends',
@@ -35,12 +35,6 @@ router.get('/quitfriends',
   admin.ensureIsAdmin,
   quitFriends
 )
-// Post because this is a secured request
-router.post('/remove',
-  signatureValidator.signature,
-  checkSignature,
-  removePods
-)
 
 // ---------------------------------------------------------------------------
 
@@ -67,7 +61,7 @@ function addPods (req, res, next) {
     },
 
     function fetchMyCertificate (callback) {
-      friends.getMyCertificate(function (err, cert) {
+      peertubeCrypto.getMyPublicCert(function (err, cert) {
         if (err) {
           logger.error('Cannot read cert file.')
           return callback(err)
@@ -79,7 +73,7 @@ function addPods (req, res, next) {
   ], function (err, cert) {
     if (err) return next(err)
 
-    return res.json({ cert: cert })
+    return res.json({ cert: cert, email: constants.CONFIG.ADMIN.EMAIL })
   })
 }
 
@@ -106,24 +100,6 @@ function makeFriends (req, res, next) {
   res.type('json').status(204).end()
 }
 
-function removePods (req, res, next) {
-  const host = req.body.signature.host
-
-  waterfall([
-    function loadPod (callback) {
-      db.Pod.loadByHost(host, callback)
-    },
-
-    function deletePod (pod, callback) {
-      pod.destroy().asCallback(callback)
-    }
-  ], function (err) {
-    if (err) return next(err)
-
-    return res.type('json').status(204).end()
-  })
-}
-
 function quitFriends (req, res, next) {
   friends.quitFriends(function (err) {
     if (err) return next(err)