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 public function handle(): void
{ {
MultiDB::setDb($this->email_service->company->db); MultiDB::setDb($this->email_service->company->db);
/* Perform final checks */ /* Perform final checks */
@ -97,10 +98,8 @@ class EmailMailer implements ShouldQueue
} catch (\Exception | \RuntimeException | \Google\Service\Exception $e) { } catch (\Exception | \RuntimeException | \Google\Service\Exception $e) {
nlog("error failed with {$e->getMessage()}"); nlog("Mailer failed with {$e->getMessage()}");
$this->cleanUpMailers();
$message = $e->getMessage(); $message = $e->getMessage();
/** /**
@ -117,17 +116,32 @@ class EmailMailer implements ShouldQueue
$message = $message_body->Message; $message = $message_body->Message;
nlog($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 */ /* Releasing immediately does not add in the backoff */
if(Ninja::isHosted() && (!$e instanceof ClientException)) $this->release($this->backoff()[$this->attempts()-1]);
app('sentry')->captureException($e);
$message = null; $message = null;
$this->cleanUpMailers();
} }