Fixing support for Github and Bitbucket web hooks.

This commit is contained in:
Dan Cryer 2014-12-01 17:30:44 +00:00
parent 0357103013
commit 8f169ae837

View file

@ -52,20 +52,7 @@ class WebhookController extends \PHPCI\Controller
*/ */
public function bitbucket($project) public function bitbucket($project)
{ {
switch ($_SERVER['CONTENT_TYPE']) { $payload = json_decode($this->getParam('payload'), true);
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');
}
foreach ($payload['commits'] as $commit) { foreach ($payload['commits'] as $commit) {
try { try {
@ -119,7 +106,19 @@ class WebhookController extends \PHPCI\Controller
*/ */
public function github($project) 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: // Handle Pull Request web hooks:
if (array_key_exists('pull_request', $payload)) { if (array_key_exists('pull_request', $payload)) {