From 8a0fded7ca9ae1f62274e694d033ee8960c6404d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 6 May 2022 13:05:25 +1000 Subject: [PATCH] Fixes for gmail notifications when credentials expire --- app/Jobs/Mail/NinjaMailerJob.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 2f90b46ac115..c128088de30d 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -226,10 +226,10 @@ class NinjaMailerJob implements ShouldQueue if(!$user->oauth_user_token) { $this->company->account->gmailCredentialNotification(); - return; + $this->nmo->settings->email_sending_method = 'default'; + return $this->setMailDriver(); } - /* * Now that our token is refreshed and valid we can boot the * mail driver at runtime and also set the token which will persist @@ -238,6 +238,12 @@ class NinjaMailerJob implements ShouldQueue $token = $user->oauth_user_token->access_token; + if(!$token) { + $this->company->account->gmailCredentialNotification(); + $this->nmo->settings->email_sending_method = 'default'; + return $this->setMailDriver(); + } + $this->nmo ->mailable ->from($user->email, $user->name())