1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Fixes for Emailer to use the appropriate backoff()

This commit is contained in:
David Bomba 2023-01-29 14:32:00 +11:00
parent a896faf0bf
commit 94a84dfb15

View File

@ -64,6 +64,7 @@ class EmailMailer implements ShouldQueue
public function handle(): void
{
MultiDB::setDb($this->email_service->company->db);
/* Perform final checks */
@ -97,10 +98,8 @@ class EmailMailer implements ShouldQueue
} catch (\Exception | \RuntimeException | \Google\Service\Exception $e) {
nlog("error failed with {$e->getMessage()}");
nlog("Mailer failed with {$e->getMessage()}");
$this->cleanUpMailers();
$message = $e->getMessage();
/**
@ -117,17 +116,32 @@ class EmailMailer implements ShouldQueue
$message = $message_body->Message;
nlog($message);
}
$this->fail();
$this->cleanUpMailers();
return;
}
//only report once, not on all tries
if($this->attempts() == $this->tries)
{
/* If the is an entity attached to the message send a failure mailer */
$this->entityEmailFailed($message);
/* Don't send postmark failures to Sentry */
if(Ninja::isHosted() && (!$e instanceof ClientException))
app('sentry')->captureException($e);
}
/* If the is an entity attached to the message send a failure mailer */
$this->entityEmailFailed($message);
/* Don't send postmark failures to Sentry */
if(Ninja::isHosted() && (!$e instanceof ClientException))
app('sentry')->captureException($e);
/* Releasing immediately does not add in the backoff */
$this->release($this->backoff()[$this->attempts()-1]);
$message = null;
$this->cleanUpMailers();
}