Fixes for webhook bug

This commit is contained in:
David Bomba 2021-07-20 08:39:04 +10:00
parent 46852794aa
commit 48c5c56a4a
2 changed files with 10 additions and 9 deletions

View File

@ -111,12 +111,9 @@ class WebhookHandler implements ShouldQueue
try {
$response = $client->post($subscription->target_url, [
RequestOptions::JSON => $data, // or 'json' => [...]
]);
if ($response->getStatusCode() == 410 || $response->getStatusCode() == 200)
$subscription->delete();
$response = $client->post($subscription->target_url, [
RequestOptions::JSON => $data, // or 'json' => [...]
]);
SystemLogger::dispatch(
$response,
@ -127,10 +124,13 @@ class WebhookHandler implements ShouldQueue
$this->company
);
// if ($response->getStatusCode() == 410 || $response->getStatusCode() == 200)
// return true;// $subscription->delete();
}
catch(\Exception $e){
// nlog($e->getMessage());
nlog($e->getMessage());
SystemLogger::dispatch(
$e->getMessage(),
@ -143,8 +143,6 @@ class WebhookHandler implements ShouldQueue
}
}
public function failed($exception)

View File

@ -19,6 +19,8 @@ use App\Models\Webhook;
class InvoiceObserver
{
public $afterCommit = true;
/**
* Handle the client "created" event.
*
@ -27,6 +29,7 @@ class InvoiceObserver
*/
public function created(Invoice $invoice)
{
$subscriptions = Webhook::where('company_id', $invoice->company->id)
->where('event_id', Webhook::EVENT_CREATE_INVOICE)
->exists();