1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 00:41:34 +02:00

Try / catch for webhooks

This commit is contained in:
David Bomba 2021-01-17 15:37:55 +11:00
parent c4bfb33dbf
commit ebd9a2c328

View File

@ -108,17 +108,29 @@ class WebhookHandler implements ShouldQueue
$client = new Client(['headers' => array_merge($base_headers, $headers)]);
try {
$response = $client->post($subscription->target_url, [
RequestOptions::JSON => $data, // or 'json' => [...]
]);
nlog($response);
if ($response->getStatusCode() == 410 || $response->getStatusCode() == 200) {
$subscription->delete();
}
if ($response->getStatusCode() == 410 || $response->getStatusCode() == 200)
$subscription->delete();
SystemLogger::dispatch(
SystemLogger::dispatch(
$response,
SystemLog::CATEGORY_WEBHOOK,
SystemLog::EVENT_WEBHOOK_RESPONSE,
SystemLog::TYPE_WEBHOOK_RESPONSE,
$this->company->clients->first(),
);
}
catch(\Exception $e){
// nlog($e->getMessage());
SystemLogger::dispatch(
$e->getMessage(),
SystemLog::CATEGORY_WEBHOOK,
SystemLog::EVENT_WEBHOOK_RESPONSE,
@ -126,6 +138,10 @@ class WebhookHandler implements ShouldQueue
$this->company->clients->first(),
);
}
}
public function failed($exception)