|
|
@ -49,6 +49,9 @@ function fulcrm_webhook_webhook( $uuid ) {
|
|
|
|
$payload_error_msg = json_last_error_msg();
|
|
|
|
$payload_error_msg = json_last_error_msg();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$client_id = variable_get( 'fulcrm_apiv2_client_id' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( fulcrm_apiv2_prevent_loop( $headers ) ) {
|
|
|
|
switch ( $method ) {
|
|
|
|
switch ( $method ) {
|
|
|
|
case 'GET':
|
|
|
|
case 'GET':
|
|
|
|
drupal_json_output( array( "status" => "error", "info" => "GET requests do nothing; webhooks must be POST, PATCH, PUT, or DELETE" ) );
|
|
|
|
drupal_json_output( array( "status" => "error", "info" => "GET requests do nothing; webhooks must be POST, PATCH, PUT, or DELETE" ) );
|
|
|
@ -58,13 +61,18 @@ function fulcrm_webhook_webhook( $uuid ) {
|
|
|
|
case 'PATCH':
|
|
|
|
case 'PATCH':
|
|
|
|
case 'PUT':
|
|
|
|
case 'PUT':
|
|
|
|
if ( $payload === null ) {
|
|
|
|
if ( $payload === null ) {
|
|
|
|
// actually do something :)
|
|
|
|
|
|
|
|
drupal_json_output( array( 'status' => 'error', 'info' => $payload_error_msg ) );
|
|
|
|
drupal_json_output( array( 'status' => 'error', 'info' => $payload_error_msg ) );
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// actually do something :)
|
|
|
|
drupal_json_output( array( 'status' => 'ok', 'headers' => $headers, 'method' => $method ) );
|
|
|
|
drupal_json_output( array( 'status' => 'ok', 'headers' => $headers, 'method' => $method ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
|
|
|
|
drupal_json_output( array( 'status' => 'error', 'info' => 'unsupported method' ) );
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
drupal_json_output( array( 'status' => 'ok', 'info' => 'loop prevention' ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
drupal_access_denied();
|
|
|
|
drupal_access_denied();
|
|
|
|