1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Add flagging abilities to accounts table

This commit is contained in:
David Bomba 2022-06-30 10:11:55 +10:00
parent aa7c3a0ce0
commit 127e9f723f
4 changed files with 38 additions and 1 deletions

View File

@ -11,6 +11,7 @@
namespace App\Factory;
use App\Models\CompanyUser;
use App\Models\User;
class UserFactory

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFlagToAccountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('accounts', function (Blueprint $table) {
$table->boolean('is_flagged')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}