Changed http return code to 200 if the command was parsed successfully, but a civiCRM error occured. In that case we shouldn't return an error code, because it's an internal error

This commit is contained in:
Philipp Batroff 2019-07-18 12:18:38 +02:00
parent f83fc0c77e
commit 917af8650d
1 changed files with 8 additions and 1 deletions

View File

@ -110,6 +110,7 @@ function webhook2api_processConfiguration($configuration, $post_input) {
$result = webhook2api_callCiviApi($configuration, $d);
if(isset($result['internal_error'])) {
// internal communication Error occured. Aborting process
civiproxy_log("Webhook2API[{$configuration['name']}]: internal error occured: " . json_encode($result['internal_error']));
return $result['internal_error'];
}
if (!empty($result['values']['http_code'])) {
@ -123,6 +124,7 @@ function webhook2api_processConfiguration($configuration, $post_input) {
$result = webhook2api_callCiviApi($configuration, $data);
if(isset($result['internal_error'])) {
// internal communication Error occured. Aborting process
civiproxy_log("Webhook2API[{$configuration['name']}]: internal error occured: " . json_encode($result['internal_error']));
return $result['internal_error'];
}
if (!empty($result['values']['http_code'])) {
@ -131,15 +133,20 @@ function webhook2api_processConfiguration($configuration, $post_input) {
$http_code = 403;
}
}
if ($http_code != '200') {
// we received and parsed the webhook event successfully, but an error occured with civicrm:
civiproxy_log("Webhook2API[{$configuration['name']}]: Internal CiviCRM Error. Error Code: {$http_code}. Full Message: " . json_encode($result));
}
// process result
if (!empty($configuration['response_mapping']) && is_array($configuration['response_mapping'])) {
// TODO: implement
//error_log("Webhook2API.response_mapping: not implemented!");
http_response_code('200');
} else {
// default behaviour:
http_response_code($http_code);
http_response_code('200');
}
// all done
exit();