Fixes for gmail notifications when credentials expire

This commit is contained in:
David Bomba 2022-05-06 13:05:25 +10:00
parent be89ac9362
commit 8a0fded7ca

View File

@ -226,10 +226,10 @@ class NinjaMailerJob implements ShouldQueue
if(!$user->oauth_user_token) { if(!$user->oauth_user_token) {
$this->company->account->gmailCredentialNotification(); $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 * Now that our token is refreshed and valid we can boot the
* mail driver at runtime and also set the token which will persist * 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; $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 $this->nmo
->mailable ->mailable
->from($user->email, $user->name()) ->from($user->email, $user->name())