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,9 +98,7 @@ 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();
@ -118,8 +117,16 @@ class EmailMailer implements ShouldQueue
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 */ /* If the is an entity attached to the message send a failure mailer */
$this->entityEmailFailed($message); $this->entityEmailFailed($message);
@ -127,7 +134,14 @@ class EmailMailer implements ShouldQueue
if(Ninja::isHosted() && (!$e instanceof ClientException)) if(Ninja::isHosted() && (!$e instanceof ClientException))
app('sentry')->captureException($e); app('sentry')->captureException($e);
}
/* Releasing immediately does not add in the backoff */
$this->release($this->backoff()[$this->attempts()-1]);
$message = null; $message = null;
$this->cleanUpMailers();
} }