mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Email Quotas for hosted
This commit is contained in:
parent
6202762bbf
commit
0f2ed3fe97
@ -228,7 +228,8 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* On the hosted platform, if the user is over the email quotas, we do not send the email. */
|
/* On the hosted platform, if the user is over the email quotas, we do not send the email. */
|
||||||
//if(Ninja::isHosted())
|
if(Ninja::isHosted() && $this->company->account->emailQuotaExceeded())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -18,6 +18,7 @@ use Carbon\Carbon;
|
|||||||
use DateTime;
|
use DateTime;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Laracasts\Presenter\PresentableTrait;
|
use Laracasts\Presenter\PresentableTrait;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
class Account extends BaseModel
|
class Account extends BaseModel
|
||||||
{
|
{
|
||||||
@ -341,4 +342,22 @@ class Account extends BaseModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDailyEmailLimit()
|
||||||
|
{
|
||||||
|
$limit = config('ninja.daily_email_limit');
|
||||||
|
|
||||||
|
$limit += Carbon::createFromTimestamp($this->created_at)->diffInMonths() * 100;
|
||||||
|
|
||||||
|
return min($limit, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function emailQuotaExceeded() :bool
|
||||||
|
{
|
||||||
|
if(is_null(Cache::get($this->key)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return Cache::get($this->key) > $this->getDailyEmailLimit();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
class AddEmailQuotaToAccountsTable extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Schema::table('accounts', function (Blueprint $table) {
|
|
||||||
$table->unsignedInteger('email_quota')->nullable()->default(300);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user