From 8f169ae837ae74db0ec747cae300b212d30f609e Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Mon, 1 Dec 2014 17:30:44 +0000 Subject: [PATCH] Fixing support for Github and Bitbucket web hooks. --- PHPCI/Controller/WebhookController.php | 29 +++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/PHPCI/Controller/WebhookController.php b/PHPCI/Controller/WebhookController.php index fb3a76d7..925cbd89 100644 --- a/PHPCI/Controller/WebhookController.php +++ b/PHPCI/Controller/WebhookController.php @@ -52,20 +52,7 @@ class WebhookController extends \PHPCI\Controller */ public function bitbucket($project) { - switch ($_SERVER['CONTENT_TYPE']) { - case 'application/json': - $payload = json_decode(file_get_contents('php://input'), true); - break; - - case 'application/x-www-form-urlencoded': - $payload = json_decode($this->getParam('payload'), true); - break; - - default: - header('HTTP/1.1 400 Bad Request'); - die('Request content type not supported'); - } - + $payload = json_decode($this->getParam('payload'), true); foreach ($payload['commits'] as $commit) { try { @@ -119,7 +106,19 @@ class WebhookController extends \PHPCI\Controller */ public function github($project) { - $payload = json_decode($this->getParam('payload'), true); + switch ($_SERVER['CONTENT_TYPE']) { + case 'application/json': + $payload = json_decode(file_get_contents('php://input'), true); + break; + + case 'application/x-www-form-urlencoded': + $payload = json_decode($this->getParam('payload'), true); + break; + + default: + header('HTTP/1.1 400 Bad Request'); + die('Request content type not supported'); + } // Handle Pull Request web hooks: if (array_key_exists('pull_request', $payload)) {