1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

fixes for validating expense_mailbox in company request

This commit is contained in:
paulwer 2024-08-28 07:33:03 +02:00
parent 13dae4f524
commit 1f92ea0108
4 changed files with 6 additions and 5 deletions

View File

@ -76,7 +76,7 @@ class UpdateCompanyRequest extends Request
$rules['subdomain'] = ['nullable', 'regex:/^[a-zA-Z0-9.-]+[a-zA-Z0-9]$/', new ValidSubdomain()];
}
$rules['expense_mailbox'] = new ValidExpenseMailbox();
$rules['expense_mailbox'] = ['email', 'nullable', new ValidExpenseMailbox()];
return $rules;
}

View File

@ -14,6 +14,7 @@ namespace App\Http\ValidationRules\Company;
use App\Libraries\MultiDB;
use App\Utils\Ninja;
use Illuminate\Contracts\Validation\Rule;
use Symfony\Component\Validator\Constraints\EmailValidator;
/**
* Class ValidCompanyQuantity.
@ -47,7 +48,7 @@ class ValidExpenseMailbox implements Rule
// Validate Schema
$validated = false;
foreach ($this->endings as $ending) {
if (str_ends_with($ending, $value)) {
if (str_ends_with($value, $ending)) {
$validated = true;
break;
}

View File

@ -113,7 +113,7 @@ class MultiDB
{
if (!config('ninja.db.multi_db_enabled')) {
return Company::where("expense_mailbox", $expense_mailbox)->exists();
return !Company::where("expense_mailbox", $expense_mailbox)->exists();
}
if (in_array($expense_mailbox, self::$protected_expense_mailboxes)) {

View File

@ -210,8 +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' => $company->inbound_mailbox_blacklist,
'inbound_mailbox_whitelist' => $company->inbound_mailbox_whitelist,
'inbound_mailbox_blacklist' => (string) $company->inbound_mailbox_blacklist,
'inbound_mailbox_whitelist' => (string) $company->inbound_mailbox_whitelist,
'smtp_host' => (string) $company->smtp_host ?? '',
'smtp_port' => (int) $company->smtp_port ?? 25,
'smtp_encryption' => (string) $company->smtp_encryption ?? 'tls',