diff --git a/app/Factory/UserFactory.php b/app/Factory/UserFactory.php index baba2fff25..da56a18387 100644 --- a/app/Factory/UserFactory.php +++ b/app/Factory/UserFactory.php @@ -11,6 +11,7 @@ namespace App\Factory; +use App\Models\CompanyUser; use App\Models\User; class UserFactory diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index fe5576fbc5..6e7296e96c 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -308,8 +308,9 @@ class NinjaMailerJob implements ShouldQueue private function preFlightChecksFail() { + /* If we are migrating data we don't want to fire any emails */ - if ($this->nmo->company->is_disabled && !$this->override) + if($this->nmo->company->is_disabled && !$this->override) return true; /* On the hosted platform we set default contacts a @example.com email address - we shouldn't send emails to these types of addresses */ @@ -324,6 +325,9 @@ class NinjaMailerJob implements ShouldQueue if(Ninja::isHosted() && $this->company->account && $this->company->account->emailQuotaExceeded()) return true; + if(Ninja::isHosted() && $this->company->account && $this->nmo->company->account->is_flagged) + return true; + /* Ensure the user has a valid email address */ if(!str_contains($this->nmo->to_user->email, "@")) return true; diff --git a/app/Models/Account.php b/app/Models/Account.php index d41ec4e952..a9ff4020ca 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -373,6 +373,8 @@ class Account extends BaseModel public function getDailyEmailLimit() { + if($this->is_flagged) + return 0; if(Carbon::createFromTimestamp($this->created_at)->diffInWeeks() == 0) return 20; diff --git a/database/migrations/2022_06_30_000126_add_flag_to_accounts_table.php b/database/migrations/2022_06_30_000126_add_flag_to_accounts_table.php new file mode 100644 index 0000000000..7118a7d7f5 --- /dev/null +++ b/database/migrations/2022_06_30_000126_add_flag_to_accounts_table.php @@ -0,0 +1,30 @@ +boolean('is_flagged')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + } +}