From 60d9a33f0d5001f3cb2ecf6fcbbc99975ac94237 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 15 Jan 2023 15:22:29 +1100 Subject: [PATCH 1/2] Minor fixes for ninjamailer --- app/Jobs/Mail/NinjaMailerJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 6c3c941b5f67..f331e3597da2 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -90,7 +90,7 @@ class NinjaMailerJob implements ShouldQueue $this->company = Company::where('company_key', $this->nmo->company->company_key)->first(); /* If any pre conditions fail, we return early here */ - if($this->preFlightChecksFail()) + if(!$this->company || $this->preFlightChecksFail()) return; /* Set the email driver */ From 26e4b6c74068c2e135caf2523688f2cd6402ddc5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 15 Jan 2023 15:36:00 +1100 Subject: [PATCH 2/2] Fixes for client mailers --- app/Jobs/Mail/NinjaMailerJob.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index f331e3597da2..b1c7ed2931ea 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -350,7 +350,10 @@ class NinjaMailerJob implements ShouldQueue { $sending_user = $this->nmo->settings->gmail_sending_user_id; - $user = User::find($this->decodePrimaryKey($sending_user)); + if($sending_user == "0") + $user = $this->company->owner(); + else + $user = User::find($this->decodePrimaryKey($sending_user)); return $user; } @@ -406,14 +409,6 @@ class NinjaMailerJob implements ShouldQueue private function setOfficeMailer() { $user = $this->resolveSendingUser(); - - /* Always ensure the user is set on the correct account */ - // if($user->account_id != $this->company->account_id){ - - // $this->nmo->settings->email_sending_method = 'default'; - // return $this->setMailDriver(); - - // } $this->checkValidSendingUser($user);