mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 06:04:30 -04:00
renaming inbound_mailbox to expense_mailbox
This commit is contained in:
parent
b7a29bb2c7
commit
b7378b9b10
@ -47,7 +47,7 @@ class StoreCompanyRequest extends Request
|
||||
$rules['company_logo'] = 'mimes:jpeg,jpg,png,gif|max:10000'; // max 10000kb
|
||||
$rules['settings'] = new ValidSettingsRule();
|
||||
|
||||
if (isset ($input['portal_mode']) && ($input['portal_mode'] == 'domain' || $input['portal_mode'] == 'iframe')) {
|
||||
if (isset($input['portal_mode']) && ($input['portal_mode'] == 'domain' || $input['portal_mode'] == 'iframe')) {
|
||||
$rules['portal_domain'] = 'sometimes|url';
|
||||
} else {
|
||||
if (Ninja::isHosted()) {
|
||||
@ -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_port'] = 'sometimes|integer|nullable';
|
||||
@ -75,39 +75,39 @@ class StoreCompanyRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if (!isset ($input['name'])) {
|
||||
if (!isset($input['name'])) {
|
||||
$input['name'] = 'Untitled Company';
|
||||
}
|
||||
|
||||
if (isset ($input['google_analytics_url'])) {
|
||||
if (isset($input['google_analytics_url'])) {
|
||||
$input['google_analytics_key'] = $input['google_analytics_url'];
|
||||
}
|
||||
|
||||
if (isset ($input['portal_domain'])) {
|
||||
if (isset($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')) {
|
||||
unset($input['inbound_mailbox']);
|
||||
if (isset($input['expense_mailbox']) && Ninja::isHosted() && !($this->company->account->isPaid() && $this->company->account->plan == 'enterprise')) {
|
||||
unset($input['expense_mailbox']);
|
||||
}
|
||||
|
||||
if (Ninja::isHosted() && !isset ($input['subdomain'])) {
|
||||
if (Ninja::isHosted() && !isset($input['subdomain'])) {
|
||||
$input['subdomain'] = MultiDB::randomSubdomainGenerator();
|
||||
}
|
||||
|
||||
if (isset ($input['smtp_username']) && strlen(str_replace("*", "", $input['smtp_username'])) < 2) {
|
||||
if (isset($input['smtp_username']) && strlen(str_replace("*", "", $input['smtp_username'])) < 2) {
|
||||
unset($input['smtp_username']);
|
||||
}
|
||||
|
||||
if (isset ($input['smtp_password']) && strlen(str_replace("*", "", $input['smtp_password'])) < 2) {
|
||||
if (isset($input['smtp_password']) && strlen(str_replace("*", "", $input['smtp_password'])) < 2) {
|
||||
unset($input['smtp_password']);
|
||||
}
|
||||
|
||||
if (isset ($input['smtp_port'])) {
|
||||
if (isset($input['smtp_port'])) {
|
||||
$input['smtp_port'] = (int) $input['smtp_port'];
|
||||
}
|
||||
|
||||
if (isset ($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer']))
|
||||
if (isset($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer']))
|
||||
$input['smtp_verify_peer'] == 'true' ? true : false;
|
||||
|
||||
$this->replace($input);
|
||||
|
@ -66,7 +66,7 @@ class UpdateCompanyRequest extends Request
|
||||
// $rules['smtp_verify_peer'] = 'sometimes|string';
|
||||
|
||||
|
||||
if (isset ($input['portal_mode']) && ($input['portal_mode'] == 'domain' || $input['portal_mode'] == 'iframe')) {
|
||||
if (isset($input['portal_mode']) && ($input['portal_mode'] == 'domain' || $input['portal_mode'] == 'iframe')) {
|
||||
$rules['portal_domain'] = 'bail|nullable|sometimes|url';
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ class UpdateCompanyRequest extends Request
|
||||
$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;
|
||||
}
|
||||
@ -83,40 +83,40 @@ class UpdateCompanyRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if (isset ($input['portal_domain']) && strlen($input['portal_domain']) > 1) {
|
||||
if (isset($input['portal_domain']) && strlen($input['portal_domain']) > 1) {
|
||||
$input['portal_domain'] = $this->addScheme($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')) {
|
||||
unset($input['inbound_mailbox']);
|
||||
if (isset($input['expense_mailbox']) && Ninja::isHosted() && !($this->company->account->isPaid() && $this->company->account->plan == 'enterprise')) {
|
||||
unset($input['expense_mailbox']);
|
||||
}
|
||||
|
||||
if (isset ($input['settings'])) {
|
||||
if (isset($input['settings'])) {
|
||||
$input['settings'] = (array) $this->filterSaveableSettings($input['settings']);
|
||||
}
|
||||
|
||||
if (isset ($input['subdomain']) && $this->company->subdomain == $input['subdomain']) {
|
||||
if (isset($input['subdomain']) && $this->company->subdomain == $input['subdomain']) {
|
||||
unset($input['subdomain']);
|
||||
}
|
||||
|
||||
if (isset ($input['e_invoice_certificate_passphrase']) && empty ($input['e_invoice_certificate_passphrase'])) {
|
||||
if (isset($input['e_invoice_certificate_passphrase']) && empty($input['e_invoice_certificate_passphrase'])) {
|
||||
unset($input['e_invoice_certificate_passphrase']);
|
||||
}
|
||||
|
||||
if (isset ($input['smtp_username']) && strlen(str_replace("*", "", $input['smtp_username'])) < 2) {
|
||||
if (isset($input['smtp_username']) && strlen(str_replace("*", "", $input['smtp_username'])) < 2) {
|
||||
unset($input['smtp_username']);
|
||||
}
|
||||
|
||||
if (isset ($input['smtp_password']) && strlen(str_replace("*", "", $input['smtp_password'])) < 2) {
|
||||
if (isset($input['smtp_password']) && strlen(str_replace("*", "", $input['smtp_password'])) < 2) {
|
||||
unset($input['smtp_password']);
|
||||
}
|
||||
|
||||
if (isset ($input['smtp_port'])) {
|
||||
if (isset($input['smtp_port'])) {
|
||||
$input['smtp_port'] = (int) $input['smtp_port'];
|
||||
}
|
||||
|
||||
if (isset ($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer'])) {
|
||||
if (isset($input['smtp_verify_peer']) && is_string($input['smtp_verify_peer'])) {
|
||||
$input['smtp_verify_peer'] == 'true' ? true : false;
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ class UpdateCompanyRequest extends Request
|
||||
}
|
||||
}
|
||||
|
||||
if (isset ($settings['email_style_custom'])) {
|
||||
if (isset($settings['email_style_custom'])) {
|
||||
$settings['email_style_custom'] = str_replace(['{!!', '!!}', '{{', '}}', '@if(', '@endif', '@isset', '@unless', '@auth', '@empty', '@guest', '@env', '@section', '@switch', '@foreach', '@while', '@include', '@each', '@once', '@push', '@use', '@forelse', '@verbatim', '<?php', '@php', '@for'], '', $settings['email_style_custom']);
|
||||
}
|
||||
|
||||
|
@ -31,19 +31,19 @@ class ValidExpenseMailbox implements Rule
|
||||
public function __construct(string $company_key, bool $isEnterprise = false)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
if (empty ($value)) {
|
||||
if (empty($value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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;
|
||||
return MultiDB::checkInboundMailboxAvailable($value);
|
||||
return MultiDB::checkExpenseMailboxAvailable($value);
|
||||
}
|
||||
|
||||
// Validate Schema
|
||||
@ -59,7 +59,7 @@ class ValidExpenseMailbox implements Rule
|
||||
return false;
|
||||
|
||||
$this->validated_schema = true;
|
||||
return MultiDB::checkInboundMailboxAvailable($value);
|
||||
return MultiDB::checkExpenseMailboxAvailable($value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,8 +68,8 @@ class ValidExpenseMailbox implements Rule
|
||||
public function message()
|
||||
{
|
||||
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
|
||||
$company = MultiDB::findAndSetDbByInboundMailbox($recipient);
|
||||
$company = MultiDB::findAndSetDbByExpenseMailbox($recipient);
|
||||
if (!$company) {
|
||||
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
|
||||
|
@ -176,7 +176,7 @@ class ProcessMailgunInboundWebhook implements ShouldQueue
|
||||
}
|
||||
|
||||
// match company
|
||||
$company = MultiDB::findAndSetDbByInboundMailbox($to);
|
||||
$company = MultiDB::findAndSetDbByExpenseMailbox($to);
|
||||
if (!$company) {
|
||||
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
|
||||
|
@ -73,7 +73,7 @@ class MultiDB
|
||||
'socket',
|
||||
];
|
||||
|
||||
private static $protected_inbound_mailboxes = [];
|
||||
private static $protected_expense_mailboxes = [];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
@ -109,21 +109,21 @@ class MultiDB
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function checkInboundMailboxAvailable($inbound_mailbox): bool
|
||||
public static function checkExpenseMailboxAvailable($expense_mailbox): bool
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
$current_db = config('database.default');
|
||||
|
||||
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);
|
||||
|
||||
return false;
|
||||
@ -515,16 +515,16 @@ class MultiDB
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function findAndSetDbByInboundMailbox($inbound_mailbox)
|
||||
public static function findAndSetDbByExpenseMailbox($expense_mailbox)
|
||||
{
|
||||
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');
|
||||
|
||||
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);
|
||||
|
||||
return $company;
|
||||
|
@ -111,8 +111,8 @@ use Laracasts\Presenter\PresentableTrait;
|
||||
* @property int $convert_expense_currency
|
||||
* @property int $notify_vendor_when_paid
|
||||
* @property int $invoice_task_hours
|
||||
* @property string|null $inbound_mailbox
|
||||
* @property boolean $inbound_mailbox_active
|
||||
* @property string|null $expense_mailbox
|
||||
* @property boolean $expense_mailbox_active
|
||||
* @property bool $inbound_mailbox_allow_company_users
|
||||
* @property bool $inbound_mailbox_allow_vendors
|
||||
* @property bool $inbound_mailbox_allow_clients
|
||||
@ -369,8 +369,8 @@ class Company extends BaseModel
|
||||
'calculate_taxes',
|
||||
'tax_data',
|
||||
'e_invoice_certificate_passphrase',
|
||||
'inbound_mailbox_active',
|
||||
'inbound_mailbox', // TODO: @turbo124 custom validation: self-hosted => free change, hosted => not changeable, only changeable with env-mask
|
||||
'expense_mailbox_active',
|
||||
'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_vendors',
|
||||
'inbound_mailbox_allow_clients',
|
||||
@ -732,7 +732,7 @@ class Company extends BaseModel
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
return isset ($this->settings->language_id) && $this->language() ? $this->language()->locale : config('ninja.i18n.locale');
|
||||
return isset($this->settings->language_id) && $this->language() ? $this->language()->locale : config('ninja.i18n.locale');
|
||||
}
|
||||
|
||||
public function getLogo(): ?string
|
||||
|
@ -54,7 +54,7 @@ class InboundMailEngine
|
||||
$isUnknownRecipent = true;
|
||||
|
||||
// Expense Mailbox => will create an expense
|
||||
$company = MultiDB::findAndSetDbByInboundMailbox($email->to);
|
||||
$company = MultiDB::findAndSetDbByExpenseMailbox($email->to);
|
||||
if ($company) {
|
||||
$isUnknownRecipent = false;
|
||||
$this->createExpense($company, $email);
|
||||
@ -148,7 +148,7 @@ class InboundMailEngine
|
||||
protected function createExpense(Company $company, InboundMail $email)
|
||||
{
|
||||
// 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);
|
||||
return;
|
||||
}
|
||||
|
@ -204,8 +204,8 @@ class CompanyTransformer extends EntityTransformer
|
||||
'invoice_task_project_header' => (bool) $company->invoice_task_project_header,
|
||||
'invoice_task_item_description' => (bool) $company->invoice_task_item_description,
|
||||
'origin_tax_data' => $company->origin_tax_data ?: new \stdClass,
|
||||
'inbound_mailbox' => (bool) $company->inbound_mailbox,
|
||||
'inbound_mailbox_active' => (bool) $company->inbound_mailbox_active,
|
||||
'expense_mailbox' => (bool) $company->expense_mailbox,
|
||||
'expense_mailbox_active' => (bool) $company->expense_mailbox_active,
|
||||
'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_clients' => (bool) $company->inbound_mailbox_allow_clients,
|
||||
|
@ -237,8 +237,8 @@ return [
|
||||
'webhook_id' => env('PAYPAL_WEBHOOK_ID', null),
|
||||
],
|
||||
'inbound_mailbox' => [
|
||||
'inbound_mailbox_template' => env('INBOUND_MAILBOX_TEMPLATE', null),
|
||||
'inbound_mailbox_endings' => env('INBOUND_MAILBOX_ENDINGS', '@expense.invoicing.co'),
|
||||
'expense_mailbox_template' => env('EXPENSE_MAILBOX_TEMPLATE', null),
|
||||
'expense_mailbox_endings' => env('EXPENSE_MAILBOX_ENDINGS', '@expense.invoicing.co'),
|
||||
],
|
||||
'cloudflare' => [
|
||||
'turnstile' => [
|
||||
|
@ -12,8 +12,8 @@ return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->boolean("inbound_mailbox_active")->default(true);
|
||||
$table->string("inbound_mailbox")->nullable();
|
||||
$table->boolean("expense_mailbox_active")->default(true);
|
||||
$table->string("expense_mailbox")->nullable();
|
||||
$table->boolean("inbound_mailbox_allow_company_users")->default(false);
|
||||
$table->boolean("inbound_mailbox_allow_vendors")->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.',
|
||||
'your_password_reset_link' => 'Your Password Reset Link',
|
||||
'subdomain_taken' => 'The subdomain is already in use',
|
||||
'inbound_mailbox_taken' => 'The inbound mailbox is already in use',
|
||||
'inbound_mailbox_invalid' => 'The inbound mailbox does not match the required schema',
|
||||
'expense_mailbox_taken' => 'The inbound mailbox is already in use',
|
||||
'expense_mailbox_invalid' => 'The inbound mailbox does not match the required schema',
|
||||
'client_login' => 'Client Login',
|
||||
'converted_amount' => 'Converted Amount',
|
||||
'default' => 'Default',
|
||||
|
Loading…
x
Reference in New Issue
Block a user