mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 15:44:33 -04:00
fixes for tests
This commit is contained in:
parent
0630b9f757
commit
cdd71d60e8
@ -77,15 +77,13 @@ class WebhookHandler implements ShouldQueue
|
||||
|
||||
$subscriptions = Webhook::where('company_id', $this->company->id)
|
||||
->where('event_id', $this->event_id)
|
||||
->get();
|
||||
->cursor()
|
||||
->each(function ($subscription) {
|
||||
|
||||
if (! $subscriptions || $subscriptions->count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$subscriptions->each(function ($subscription) {
|
||||
$this->process($subscription);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private function process($subscription)
|
||||
@ -130,9 +128,27 @@ class WebhookHandler implements ShouldQueue
|
||||
$this->company
|
||||
);
|
||||
|
||||
// if ($response->getStatusCode() == 410)
|
||||
// return true; $subscription->delete();
|
||||
if ($response->getStatusCode() == 429){
|
||||
nlog("429 retry after 10 seconds internally");
|
||||
sleep(10);
|
||||
|
||||
$response = $client->post($subscription->target_url, [
|
||||
RequestOptions::JSON => $data, // or 'json' => [...]
|
||||
]);
|
||||
|
||||
SystemLogger::dispatch(
|
||||
array_merge((array) $response, $data),
|
||||
SystemLog::CATEGORY_WEBHOOK,
|
||||
SystemLog::EVENT_WEBHOOK_SUCCESS,
|
||||
SystemLog::TYPE_WEBHOOK_RESPONSE,
|
||||
$this->resolveClient(),
|
||||
$this->company
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
nlog("429 occurred in the expcetion handler");
|
||||
nlog($e->getMessage());
|
||||
|
||||
SystemLogger::dispatch(
|
||||
@ -158,6 +174,10 @@ class WebhookHandler implements ShouldQueue
|
||||
|
||||
public function failed($exception)
|
||||
{
|
||||
|
||||
sleep(2);
|
||||
|
||||
nlog(print_r($exception->getMessage(), 1));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -250,8 +250,9 @@ class SchedulerTest extends TestCase
|
||||
$method = $reflectionMethod->invoke(new SchedulerService($scheduler));
|
||||
|
||||
$scheduler->fresh();
|
||||
$offset = $this->company->timezone_offset();
|
||||
|
||||
$this->assertEquals(now()->addMonth()->format('Y-m-d'), $scheduler->next_run->format('Y-m-d'));
|
||||
$this->assertEquals(now()->startOfDay()->addMonthNoOverflow()->addSeconds($offset)->format('Y-m-d'), $scheduler->next_run->format('Y-m-d'));
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user