mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for webhook logic
This commit is contained in:
parent
fdf3f252b1
commit
3ce689a53e
@ -64,7 +64,7 @@ class InvoiceCheckLateWebhook implements ShouldQueue
|
||||
->whereBetween('due_date', [now()->subDay()->startOfDay(), now()->startOfDay()->subSecond()])
|
||||
->cursor()
|
||||
->each(function ($invoice) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company, 'client')->delay(now()->addSeconds(2));
|
||||
(new WebhookHandler(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company, 'client'))->handle();
|
||||
});
|
||||
} else {
|
||||
foreach (MultiDB::$dbs as $db) {
|
||||
@ -91,7 +91,7 @@ class InvoiceCheckLateWebhook implements ShouldQueue
|
||||
->whereBetween('due_date', [now()->subDay()->startOfDay(), now()->startOfDay()->subSecond()])
|
||||
->cursor()
|
||||
->each(function ($invoice) {
|
||||
WebhookHandler::dispatch(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company, 'client')->delay(now()->addSeconds(2));
|
||||
(new WebhookHandler(Webhook::EVENT_LATE_INVOICE, $invoice, $invoice->company, 'client'))->handle();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class WebhookHandler implements ShouldQueue
|
||||
->where('event_id', $this->event_id)
|
||||
->cursor()
|
||||
->each(function ($subscription) {
|
||||
WebhookSingle::dispatch($subscription->id, $this->entity, $this->company->db, $this->includes);
|
||||
(new WebhookSingle($subscription->id, $this->entity, $this->company->db, $this->includes))->handle();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -63,9 +63,7 @@ class WebhookSingle implements ShouldQueue
|
||||
|
||||
public function backoff()
|
||||
{
|
||||
// return [15, 35, 65, 185, 3605];
|
||||
return [rand(10, 15), rand(30, 40), rand(60, 79), rand(160, 200), rand(3000, 5000)];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,8 +148,28 @@ class WebhookSingle implements ShouldQueue
|
||||
))->handle();
|
||||
} catch (BadResponseException $e) {
|
||||
if ($e->getResponse()->getStatusCode() >= 400 && $e->getResponse()->getStatusCode() < 500) {
|
||||
|
||||
/* Some 400's should never be repeated */
|
||||
if (in_array($e->getResponse()->getStatusCode(), [404, 410, 405])) {
|
||||
|
||||
$message = "There was a problem when connecting to {$subscription->target_url} => status code ". $e->getResponse()->getStatusCode(). " This webhook call will be suspended until further action is taken.";
|
||||
|
||||
(new SystemLogger(
|
||||
['message' => $message],
|
||||
SystemLog::CATEGORY_WEBHOOK,
|
||||
SystemLog::EVENT_WEBHOOK_FAILURE,
|
||||
SystemLog::TYPE_WEBHOOK_RESPONSE,
|
||||
$this->resolveClient(),
|
||||
$this->company
|
||||
))->handle();
|
||||
|
||||
$subscription->delete();
|
||||
$this->fail();
|
||||
return;
|
||||
}
|
||||
|
||||
$message = "There was a problem when connecting to {$subscription->target_url} => status code ". $e->getResponse()->getStatusCode();
|
||||
|
||||
|
||||
nlog($message);
|
||||
|
||||
(new SystemLogger(
|
||||
@ -163,11 +181,11 @@ class WebhookSingle implements ShouldQueue
|
||||
$this->company
|
||||
))->handle();
|
||||
|
||||
/* Some 400's should never be repeated */
|
||||
if (in_array($e->getResponse()->getStatusCode(), [404, 410])) {
|
||||
if (in_array($e->getResponse()->getStatusCode(), [400])) {
|
||||
$this->fail();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->release($this->backoff()[$this->attempts()-1]);
|
||||
}
|
||||
|
9
public/build/assets/eway-credit-card-62ce5f3b.js
vendored
Normal file
9
public/build/assets/eway-credit-card-62ce5f3b.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user