Merge branch 'gogs-content-type'

This commit is contained in:
Dmitry Khomutov 2018-06-04 20:44:01 +07:00
commit 361a06a127
No known key found for this signature in database
GPG key ID: EC19426474B37AAC

View file

@ -592,11 +592,11 @@ class WebhookController extends Controller
} }
/** /**
* Called by Gogs Webhooks:
*
* @param string $projectId * @param string $projectId
* *
* @return array * @return array
*
* @throws Exception
*/ */
public function gogs($projectId) public function gogs($projectId)
{ {
@ -606,14 +606,12 @@ class WebhookController extends Controller
]); ]);
switch ($_SERVER['CONTENT_TYPE']) { switch ($_SERVER['CONTENT_TYPE']) {
case 'application/json':
$payload = json_decode(file_get_contents('php://input'), true);
break;
case 'application/x-www-form-urlencoded': case 'application/x-www-form-urlencoded':
$payload = json_decode($this->getParam('payload'), true); $payload = json_decode($this->getParam('payload'), true);
break; break;
case 'application/json':
default: default:
return ['status' => 'failed', 'error' => 'Content type not supported.', 'responseCode' => 401]; $payload = json_decode(file_get_contents('php://input'), true);
} }
// Handle Push web hooks: // Handle Push web hooks: