mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 11:14:40 -04:00
fix: reduce vars in favor for db
This commit is contained in:
parent
9c9c4a998c
commit
ef60992843
@ -117,10 +117,8 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property bool $inbound_mailbox_allow_vendors
|
||||
* @property bool $inbound_mailbox_allow_clients
|
||||
* @property bool $inbound_mailbox_allow_unknown
|
||||
* @property string|null $inbound_mailbox_whitelist_domains
|
||||
* @property string|null $inbound_mailbox_whitelist_senders
|
||||
* @property string|null $inbound_mailbox_blacklist_domains
|
||||
* @property string|null $inbound_mailbox_blacklist_senders
|
||||
* @property string|null $inbound_mailbox_whitelist
|
||||
* @property string|null $inbound_mailbox_blacklist
|
||||
* @property int $deleted_at
|
||||
* @property string $smtp_username
|
||||
* @property string $smtp_password
|
||||
@ -375,10 +373,8 @@ class Company extends BaseModel
|
||||
'inbound_mailbox_allow_vendors',
|
||||
'inbound_mailbox_allow_clients',
|
||||
'inbound_mailbox_allow_unknown',
|
||||
'inbound_mailbox_whitelist_domains',
|
||||
'inbound_mailbox_whitelist_senders',
|
||||
'inbound_mailbox_blacklist_domains',
|
||||
'inbound_mailbox_blacklist_senders',
|
||||
'inbound_mailbox_whitelist',
|
||||
'inbound_mailbox_blacklist',
|
||||
'smtp_host',
|
||||
'smtp_port',
|
||||
'smtp_encryption',
|
||||
|
@ -16,7 +16,7 @@ use App\Factory\ExpenseFactory;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Company;
|
||||
use App\Models\Company;
|
||||
use App\Models\SystemLog;
|
||||
use App\Models\VendorContact;
|
||||
use App\Services\InboundMail\InboundMail;
|
||||
@ -34,10 +34,8 @@ class InboundMailEngine
|
||||
use GeneratesCounter, SavesDocuments;
|
||||
|
||||
private ?bool $isUnknownRecipent = null;
|
||||
private array $globalBlacklistDomains = [];
|
||||
private array $globalBlacklistSenders = [];
|
||||
private array $globalWhitelistDomains = []; // only for global validation, not for allowing to send something into the company, should be used to disabled blocking for mass-senders
|
||||
private array $globalWhitelistSenders = []; // only for global validation, not for allowing to send something into the company, should be used to disabled blocking for mass-senders
|
||||
private array $globalBlacklist = [];
|
||||
private array $globalWhitelist = []; // only for global validation, not for allowing to send something into the company, should be used to disabled blocking for mass-senders
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
@ -78,17 +76,17 @@ class InboundMailEngine
|
||||
$domain = array_pop($parts);
|
||||
|
||||
// global blacklist
|
||||
if (in_array($from, $this->globalWhitelistDomains)) {
|
||||
if (in_array($from, $this->globalWhitelist)) {
|
||||
return false;
|
||||
}
|
||||
if (in_array($domain, $this->globalBlacklistDomains)) {
|
||||
if (in_array($domain, $this->globalWhitelist)) {
|
||||
return false;
|
||||
}
|
||||
if (in_array($domain, $this->globalBlacklist)) {
|
||||
nlog('E-Mail blocked, because the domain was found on globalBlocklistDomains: ' . $from);
|
||||
return true;
|
||||
}
|
||||
if (in_array($domain, $this->globalWhitelistSenders)) {
|
||||
return false;
|
||||
}
|
||||
if (in_array($from, $this->globalBlacklistSenders)) {
|
||||
if (in_array($from, $this->globalBlacklist)) {
|
||||
nlog('E-Mail blocked, because the email was found on globalBlocklistEmails: ' . $from);
|
||||
return true;
|
||||
}
|
||||
@ -210,17 +208,15 @@ class InboundMailEngine
|
||||
$domain = array_pop($parts);
|
||||
|
||||
// whitelists
|
||||
$email_whitelist = explode(",", $company->inbound_mailbox_whitelist_senders);
|
||||
if (in_array($email->from, $email_whitelist))
|
||||
$whitelist = explode(",", $company->inbound_mailbox_whitelist);
|
||||
if (in_array($email->from, $whitelist))
|
||||
return true;
|
||||
$domain_whitelist = explode(",", $company->inbound_mailbox_whitelist_domains);
|
||||
if (in_array($domain, $domain_whitelist))
|
||||
if (in_array($domain, $whitelist))
|
||||
return true;
|
||||
$email_blacklist = explode(",", $company->inbound_mailbox_blacklist_senders);
|
||||
if (in_array($email->from, $email_blacklist))
|
||||
$blacklist = explode(",", $company->inbound_mailbox_blacklist);
|
||||
if (in_array($email->from, $blacklist))
|
||||
return false;
|
||||
$domain_blacklist = explode(",", $company->inbound_mailbox_blacklist_domains);
|
||||
if (in_array($domain, $domain_blacklist))
|
||||
if (in_array($domain, $blacklist))
|
||||
return false;
|
||||
|
||||
// allow unknown
|
||||
|
@ -210,10 +210,8 @@ class CompanyTransformer extends EntityTransformer
|
||||
'inbound_mailbox_allow_vendors' => (bool) $company->inbound_mailbox_allow_vendors,
|
||||
'inbound_mailbox_allow_clients' => (bool) $company->inbound_mailbox_allow_clients,
|
||||
'inbound_mailbox_allow_unknown' => (bool) $company->inbound_mailbox_allow_unknown,
|
||||
'inbound_mailbox_blacklist_domains' => $company->inbound_mailbox_blacklist_domains,
|
||||
'inbound_mailbox_blacklist_senders' => $company->inbound_mailbox_blacklist_senders,
|
||||
'inbound_mailbox_whitelist_domains' => $company->inbound_mailbox_whitelist_domains,
|
||||
'inbound_mailbox_whitelist_senders' => $company->inbound_mailbox_whitelist_senders,
|
||||
'inbound_mailbox_blacklist' => $company->inbound_mailbox_blacklist,
|
||||
'inbound_mailbox_whitelist' => $company->inbound_mailbox_whitelist,
|
||||
'smtp_host' => (string) $company->smtp_host ?? '',
|
||||
'smtp_port' => (int) $company->smtp_port ?? 25,
|
||||
'smtp_encryption' => (string) $company->smtp_encryption ?? 'tls',
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Company;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
@ -18,10 +17,8 @@ return new class extends Migration {
|
||||
$table->boolean("inbound_mailbox_allow_vendors")->default(false);
|
||||
$table->boolean("inbound_mailbox_allow_clients")->default(false);
|
||||
$table->boolean("inbound_mailbox_allow_unknown")->default(false);
|
||||
$table->text("inbound_mailbox_whitelist_domains")->nullable();
|
||||
$table->text("inbound_mailbox_whitelist_senders")->nullable();
|
||||
$table->text("inbound_mailbox_blacklist_domains")->nullable();
|
||||
$table->text("inbound_mailbox_blacklist_senders")->nullable();
|
||||
$table->text("inbound_mailbox_whitelist")->nullable();
|
||||
$table->text("inbound_mailbox_blacklist")->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user