mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 11:04:30 -04:00
renaming inbound_mailbox to expense_mailbox
This commit is contained in:
parent
b7a29bb2c7
commit
b7378b9b10
@ -57,7 +57,7 @@ class StoreCompanyRequest extends Request
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules['inbound_mailbox'] = new ValidExpenseMailbox($this->company->key, $this->company->account->isPaid() && $this->company->account->plan == 'enterprise');
|
$rules['expense_mailbox'] = new ValidExpenseMailbox($this->company->key, $this->company->account->isPaid() && $this->company->account->plan == 'enterprise');
|
||||||
|
|
||||||
$rules['smtp_host'] = 'sometimes|string|nullable';
|
$rules['smtp_host'] = 'sometimes|string|nullable';
|
||||||
$rules['smtp_port'] = 'sometimes|integer|nullable';
|
$rules['smtp_port'] = 'sometimes|integer|nullable';
|
||||||
@ -87,8 +87,8 @@ class StoreCompanyRequest extends Request
|
|||||||
$input['portal_domain'] = rtrim(strtolower($input['portal_domain']), "/");
|
$input['portal_domain'] = rtrim(strtolower($input['portal_domain']), "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset ($input['inbound_mailbox']) && Ninja::isHosted() && !($this->company->account->isPaid() && $this->company->account->plan == 'enterprise')) {
|
if (isset($input['expense_mailbox']) && Ninja::isHosted() && !($this->company->account->isPaid() && $this->company->account->plan == 'enterprise')) {
|
||||||
unset($input['inbound_mailbox']);
|
unset($input['expense_mailbox']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ninja::isHosted() && !isset($input['subdomain'])) {
|
if (Ninja::isHosted() && !isset($input['subdomain'])) {
|
||||||
|
@ -74,7 +74,7 @@ class UpdateCompanyRequest extends Request
|
|||||||
$rules['subdomain'] = ['nullable', 'regex:/^[a-zA-Z0-9.-]+[a-zA-Z0-9]$/', new ValidSubdomain()];
|
$rules['subdomain'] = ['nullable', 'regex:/^[a-zA-Z0-9.-]+[a-zA-Z0-9]$/', new ValidSubdomain()];
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules['inbound_mailbox'] = new ValidExpenseMailbox($this->company->key, $this->company->account->isPaid() && $this->company->account->plan == 'enterprise'); // @turbo124 check if this is right
|
$rules['expense_mailbox'] = new ValidExpenseMailbox($this->company->key, $this->company->account->isPaid() && $this->company->account->plan == 'enterprise'); // @turbo124 check if this is right
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
@ -88,8 +88,8 @@ class UpdateCompanyRequest extends Request
|
|||||||
$input['portal_domain'] = rtrim(strtolower($input['portal_domain']), "/");
|
$input['portal_domain'] = rtrim(strtolower($input['portal_domain']), "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset ($input['inbound_mailbox']) && Ninja::isHosted() && !($this->company->account->isPaid() && $this->company->account->plan == 'enterprise')) {
|
if (isset($input['expense_mailbox']) && Ninja::isHosted() && !($this->company->account->isPaid() && $this->company->account->plan == 'enterprise')) {
|
||||||
unset($input['inbound_mailbox']);
|
unset($input['expense_mailbox']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($input['settings'])) {
|
if (isset($input['settings'])) {
|
||||||
|
@ -31,7 +31,7 @@ class ValidExpenseMailbox implements Rule
|
|||||||
public function __construct(string $company_key, bool $isEnterprise = false)
|
public function __construct(string $company_key, bool $isEnterprise = false)
|
||||||
{
|
{
|
||||||
$this->company_key = $company_key;
|
$this->company_key = $company_key;
|
||||||
$this->endings = explode(",", config('ninja.inbound_mailbox.inbound_mailbox_endings'));
|
$this->endings = explode(",", config('ninja.inbound_mailbox.expense_mailbox_endings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function passes($attribute, $value)
|
public function passes($attribute, $value)
|
||||||
@ -41,9 +41,9 @@ class ValidExpenseMailbox implements Rule
|
|||||||
}
|
}
|
||||||
|
|
||||||
// early return, if we dont have any additional validation
|
// early return, if we dont have any additional validation
|
||||||
if (!config('ninja.inbound_mailbox.inbound_mailbox_endings')) {
|
if (!config('ninja.inbound_mailbox.expense_mailbox_endings')) {
|
||||||
$this->validated_schema = true;
|
$this->validated_schema = true;
|
||||||
return MultiDB::checkInboundMailboxAvailable($value);
|
return MultiDB::checkExpenseMailboxAvailable($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate Schema
|
// Validate Schema
|
||||||
@ -59,7 +59,7 @@ class ValidExpenseMailbox implements Rule
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
$this->validated_schema = true;
|
$this->validated_schema = true;
|
||||||
return MultiDB::checkInboundMailboxAvailable($value);
|
return MultiDB::checkExpenseMailboxAvailable($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,8 +68,8 @@ class ValidExpenseMailbox implements Rule
|
|||||||
public function message()
|
public function message()
|
||||||
{
|
{
|
||||||
if (!$this->validated_schema)
|
if (!$this->validated_schema)
|
||||||
return ctrans('texts.inbound_mailbox_invalid');
|
return ctrans('texts.expense_mailbox_invalid');
|
||||||
|
|
||||||
return ctrans('texts.inbound_mailbox_taken');
|
return ctrans('texts.expense_mailbox_taken');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ class ProcessBrevoInboundWebhook implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
// match company
|
// match company
|
||||||
$company = MultiDB::findAndSetDbByInboundMailbox($recipient);
|
$company = MultiDB::findAndSetDbByExpenseMailbox($recipient);
|
||||||
if (!$company) {
|
if (!$company) {
|
||||||
Log::info('[ProcessBrevoInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from brevo: ' . $recipient);
|
Log::info('[ProcessBrevoInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from brevo: ' . $recipient);
|
||||||
(new InboundMailEngine())->saveMeta($this->input["From"]["Address"], $recipient); // important to save this, to protect from spam
|
(new InboundMailEngine())->saveMeta($this->input["From"]["Address"], $recipient); // important to save this, to protect from spam
|
||||||
|
@ -176,7 +176,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
// match company
|
// match company
|
||||||
$company = MultiDB::findAndSetDbByInboundMailbox($to);
|
$company = MultiDB::findAndSetDbByExpenseMailbox($to);
|
||||||
if (!$company) {
|
if (!$company) {
|
||||||
Log::info('[ProcessMailgunInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $to);
|
Log::info('[ProcessMailgunInboundWebhook] unknown Expense Mailbox occured while handling an inbound email from mailgun: ' . $to);
|
||||||
(new InboundMailEngine())->saveMeta($from, $to); // important to save this, to protect from spam
|
(new InboundMailEngine())->saveMeta($from, $to); // important to save this, to protect from spam
|
||||||
|
@ -73,7 +73,7 @@ class MultiDB
|
|||||||
'socket',
|
'socket',
|
||||||
];
|
];
|
||||||
|
|
||||||
private static $protected_inbound_mailboxes = [];
|
private static $protected_expense_mailboxes = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
@ -109,21 +109,21 @@ class MultiDB
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkInboundMailboxAvailable($inbound_mailbox): bool
|
public static function checkExpenseMailboxAvailable($expense_mailbox): bool
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!config('ninja.db.multi_db_enabled')) {
|
if (!config('ninja.db.multi_db_enabled')) {
|
||||||
return Company::where("inbound_mailbox", $inbound_mailbox)->withTrashed()->exists();
|
return Company::where("expense_mailbox", $expense_mailbox)->withTrashed()->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($inbound_mailbox, self::$protected_inbound_mailboxes)) {
|
if (in_array($expense_mailbox, self::$protected_expense_mailboxes)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$current_db = config('database.default');
|
$current_db = config('database.default');
|
||||||
|
|
||||||
foreach (self::$dbs as $db) {
|
foreach (self::$dbs as $db) {
|
||||||
if (Company::on($db)->where("inbound_mailbox", $inbound_mailbox)->withTrashed()->exists()) {
|
if (Company::on($db)->where("expense_mailbox", $expense_mailbox)->withTrashed()->exists()) {
|
||||||
self::setDb($current_db);
|
self::setDb($current_db);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -515,16 +515,16 @@ class MultiDB
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function findAndSetDbByInboundMailbox($inbound_mailbox)
|
public static function findAndSetDbByExpenseMailbox($expense_mailbox)
|
||||||
{
|
{
|
||||||
if (!config('ninja.db.multi_db_enabled')) {
|
if (!config('ninja.db.multi_db_enabled')) {
|
||||||
return Company::where("inbound_mailbox", $inbound_mailbox)->first();
|
return Company::where("expense_mailbox", $expense_mailbox)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
$current_db = config('database.default');
|
$current_db = config('database.default');
|
||||||
|
|
||||||
foreach (self::$dbs as $db) {
|
foreach (self::$dbs as $db) {
|
||||||
if ($company = Company::on($db)->where("inbound_mailbox", $inbound_mailbox)->first()) {
|
if ($company = Company::on($db)->where("expense_mailbox", $expense_mailbox)->first()) {
|
||||||
self::setDb($db);
|
self::setDb($db);
|
||||||
|
|
||||||
return $company;
|
return $company;
|
||||||
|
@ -111,8 +111,8 @@ use Laracasts\Presenter\PresentableTrait;
|
|||||||
* @property int $convert_expense_currency
|
* @property int $convert_expense_currency
|
||||||
* @property int $notify_vendor_when_paid
|
* @property int $notify_vendor_when_paid
|
||||||
* @property int $invoice_task_hours
|
* @property int $invoice_task_hours
|
||||||
* @property string|null $inbound_mailbox
|
* @property string|null $expense_mailbox
|
||||||
* @property boolean $inbound_mailbox_active
|
* @property boolean $expense_mailbox_active
|
||||||
* @property bool $inbound_mailbox_allow_company_users
|
* @property bool $inbound_mailbox_allow_company_users
|
||||||
* @property bool $inbound_mailbox_allow_vendors
|
* @property bool $inbound_mailbox_allow_vendors
|
||||||
* @property bool $inbound_mailbox_allow_clients
|
* @property bool $inbound_mailbox_allow_clients
|
||||||
@ -369,8 +369,8 @@ class Company extends BaseModel
|
|||||||
'calculate_taxes',
|
'calculate_taxes',
|
||||||
'tax_data',
|
'tax_data',
|
||||||
'e_invoice_certificate_passphrase',
|
'e_invoice_certificate_passphrase',
|
||||||
'inbound_mailbox_active',
|
'expense_mailbox_active',
|
||||||
'inbound_mailbox', // TODO: @turbo124 custom validation: self-hosted => free change, hosted => not changeable, only changeable with env-mask
|
'expense_mailbox', // TODO: @turbo124 custom validation: self-hosted => free change, hosted => not changeable, only changeable with env-mask
|
||||||
'inbound_mailbox_allow_company_users',
|
'inbound_mailbox_allow_company_users',
|
||||||
'inbound_mailbox_allow_vendors',
|
'inbound_mailbox_allow_vendors',
|
||||||
'inbound_mailbox_allow_clients',
|
'inbound_mailbox_allow_clients',
|
||||||
|
@ -54,7 +54,7 @@ class InboundMailEngine
|
|||||||
$isUnknownRecipent = true;
|
$isUnknownRecipent = true;
|
||||||
|
|
||||||
// Expense Mailbox => will create an expense
|
// Expense Mailbox => will create an expense
|
||||||
$company = MultiDB::findAndSetDbByInboundMailbox($email->to);
|
$company = MultiDB::findAndSetDbByExpenseMailbox($email->to);
|
||||||
if ($company) {
|
if ($company) {
|
||||||
$isUnknownRecipent = false;
|
$isUnknownRecipent = false;
|
||||||
$this->createExpense($company, $email);
|
$this->createExpense($company, $email);
|
||||||
@ -148,7 +148,7 @@ class InboundMailEngine
|
|||||||
protected function createExpense(Company $company, InboundMail $email)
|
protected function createExpense(Company $company, InboundMail $email)
|
||||||
{
|
{
|
||||||
// Skipping executions: will not result in not saving Metadata to prevent usage of these conditions, to spam
|
// Skipping executions: will not result in not saving Metadata to prevent usage of these conditions, to spam
|
||||||
if (!($company?->inbound_mailbox_active ?: false)) {
|
if (!($company?->expense_mailbox_active ?: false)) {
|
||||||
$this->logBlocked($company, 'mailbox not active for this company. from: ' . $email->from);
|
$this->logBlocked($company, 'mailbox not active for this company. from: ' . $email->from);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -204,8 +204,8 @@ class CompanyTransformer extends EntityTransformer
|
|||||||
'invoice_task_project_header' => (bool) $company->invoice_task_project_header,
|
'invoice_task_project_header' => (bool) $company->invoice_task_project_header,
|
||||||
'invoice_task_item_description' => (bool) $company->invoice_task_item_description,
|
'invoice_task_item_description' => (bool) $company->invoice_task_item_description,
|
||||||
'origin_tax_data' => $company->origin_tax_data ?: new \stdClass,
|
'origin_tax_data' => $company->origin_tax_data ?: new \stdClass,
|
||||||
'inbound_mailbox' => (bool) $company->inbound_mailbox,
|
'expense_mailbox' => (bool) $company->expense_mailbox,
|
||||||
'inbound_mailbox_active' => (bool) $company->inbound_mailbox_active,
|
'expense_mailbox_active' => (bool) $company->expense_mailbox_active,
|
||||||
'inbound_mailbox_allow_company_users' => (bool) $company->inbound_mailbox_allow_company_users,
|
'inbound_mailbox_allow_company_users' => (bool) $company->inbound_mailbox_allow_company_users,
|
||||||
'inbound_mailbox_allow_vendors' => (bool) $company->inbound_mailbox_allow_vendors,
|
'inbound_mailbox_allow_vendors' => (bool) $company->inbound_mailbox_allow_vendors,
|
||||||
'inbound_mailbox_allow_clients' => (bool) $company->inbound_mailbox_allow_clients,
|
'inbound_mailbox_allow_clients' => (bool) $company->inbound_mailbox_allow_clients,
|
||||||
|
@ -237,8 +237,8 @@ return [
|
|||||||
'webhook_id' => env('PAYPAL_WEBHOOK_ID', null),
|
'webhook_id' => env('PAYPAL_WEBHOOK_ID', null),
|
||||||
],
|
],
|
||||||
'inbound_mailbox' => [
|
'inbound_mailbox' => [
|
||||||
'inbound_mailbox_template' => env('INBOUND_MAILBOX_TEMPLATE', null),
|
'expense_mailbox_template' => env('EXPENSE_MAILBOX_TEMPLATE', null),
|
||||||
'inbound_mailbox_endings' => env('INBOUND_MAILBOX_ENDINGS', '@expense.invoicing.co'),
|
'expense_mailbox_endings' => env('EXPENSE_MAILBOX_ENDINGS', '@expense.invoicing.co'),
|
||||||
],
|
],
|
||||||
'cloudflare' => [
|
'cloudflare' => [
|
||||||
'turnstile' => [
|
'turnstile' => [
|
||||||
|
@ -12,8 +12,8 @@ return new class extends Migration {
|
|||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::table('companies', function (Blueprint $table) {
|
Schema::table('companies', function (Blueprint $table) {
|
||||||
$table->boolean("inbound_mailbox_active")->default(true);
|
$table->boolean("expense_mailbox_active")->default(true);
|
||||||
$table->string("inbound_mailbox")->nullable();
|
$table->string("expense_mailbox")->nullable();
|
||||||
$table->boolean("inbound_mailbox_allow_company_users")->default(false);
|
$table->boolean("inbound_mailbox_allow_company_users")->default(false);
|
||||||
$table->boolean("inbound_mailbox_allow_vendors")->default(false);
|
$table->boolean("inbound_mailbox_allow_vendors")->default(false);
|
||||||
$table->boolean("inbound_mailbox_allow_clients")->default(false);
|
$table->boolean("inbound_mailbox_allow_clients")->default(false);
|
||||||
|
@ -2494,8 +2494,8 @@ $lang = array(
|
|||||||
'local_storage_required' => 'Error: local storage is not available.',
|
'local_storage_required' => 'Error: local storage is not available.',
|
||||||
'your_password_reset_link' => 'Your Password Reset Link',
|
'your_password_reset_link' => 'Your Password Reset Link',
|
||||||
'subdomain_taken' => 'The subdomain is already in use',
|
'subdomain_taken' => 'The subdomain is already in use',
|
||||||
'inbound_mailbox_taken' => 'The inbound mailbox is already in use',
|
'expense_mailbox_taken' => 'The inbound mailbox is already in use',
|
||||||
'inbound_mailbox_invalid' => 'The inbound mailbox does not match the required schema',
|
'expense_mailbox_invalid' => 'The inbound mailbox does not match the required schema',
|
||||||
'client_login' => 'Client Login',
|
'client_login' => 'Client Login',
|
||||||
'converted_amount' => 'Converted Amount',
|
'converted_amount' => 'Converted Amount',
|
||||||
'default' => 'Default',
|
'default' => 'Default',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user