1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00

Add suppressions for user notifications

This commit is contained in:
David Bomba 2023-10-18 17:28:10 +11:00
parent e41228a115
commit 25ceba275c
13 changed files with 87 additions and 20 deletions

View File

@ -67,8 +67,6 @@ class PaymentExport extends BaseExport
$headerdisplay = $this->buildHeader(); $headerdisplay = $this->buildHeader();
nlog($headerdisplay);
$header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) { $header = collect($this->input['report_keys'])->map(function ($key, $value) use ($headerdisplay) {
return ['identifier' => $key, 'display_value' => $headerdisplay[$value]]; return ['identifier' => $key, 'display_value' => $headerdisplay[$value]];
})->toArray(); })->toArray();

View File

@ -32,12 +32,12 @@ class NinjaMailerObject
/* Variable for cascading notifications */ /* Variable for cascading notifications */
public $entity_string = false; public $entity_string = false;
/* @var bool | App\Models\InvoiceInvitation | app\Models\QuoteInvitation | app\Models\CreditInvitation | app\Models\RecurringInvoiceInvitation | app\Models\PurchaseOrderInvitation $invitation*/ /* @var bool | App\Models\InvoiceInvitation | App\Models\QuoteInvitation | App\Models\CreditInvitation | App\Models\RecurringInvoiceInvitation | App\Models\PurchaseOrderInvitation $invitation*/
public $invitation = false; public $invitation = false;
public $template = false; public $template = false;
/* @var bool | App\Models\Invoice | app\Models\Quote | app\Models\Credit | app\Models\RecurringInvoice | app\Models\PurchaseOrder $invitation*/ /* @var bool | App\Models\Invoice | App\Models\Quote | App\Models\Credit | App\Models\RecurringInvoice | App\Models\PurchaseOrder | App\Models\Payment $entity*/
public $entity = false; public $entity = false;
public $reminder_template = ''; public $reminder_template = '';

View File

@ -55,7 +55,7 @@ class UpdateUserLastLogin implements ShouldQueue
$key = "user_logged_in_{$user->id}{$event->company->db}"; $key = "user_logged_in_{$user->id}{$event->company->db}";
if ($user->ip != $ip && is_null(Cache::get($key))) { if ($user->ip != $ip && is_null(Cache::get($key)) && $user->user_logged_in_notification) {
$nmo = new NinjaMailerObject; $nmo = new NinjaMailerObject;
$nmo->mailable = new UserLoggedIn($user, $user->account->companies->first(), $ip); $nmo->mailable = new UserLoggedIn($user, $user->account->companies->first(), $ip);
$nmo->company = $user->account->companies->first(); $nmo->company = $user->account->companies->first();
@ -69,6 +69,7 @@ class UpdateUserLastLogin implements ShouldQueue
Cache::put($key, true, 60 * 24); Cache::put($key, true, 60 * 24);
$arr = json_encode(['ip' => $ip]); $arr = json_encode(['ip' => $ip]);
$arr = ctrans('texts.new_login_detected'). " {$ip}";
SystemLogger::dispatch( SystemLogger::dispatch(
$arr, $arr,

View File

@ -108,12 +108,15 @@ class TemplateEmail extends Mailable
if (strlen($settings->bcc_email) > 1) { if (strlen($settings->bcc_email) > 1) {
if (Ninja::isHosted()) { if (Ninja::isHosted()) {
if($company->account->isPaid()) {
$bccs = explode(',', str_replace(' ', '', $settings->bcc_email)); $bccs = explode(',', str_replace(' ', '', $settings->bcc_email));
$this->bcc(array_slice($bccs, 0, 2)); $this->bcc(array_slice($bccs, 0, 5));
//$this->bcc(reset($bccs)); //remove whitespace if any has been inserted. }
} else { } else {
$this->bcc(explode(',', str_replace(' ', '', $settings->bcc_email))); $this->bcc(explode(',', str_replace(' ', '', $settings->bcc_email)));
}//remove whitespace if any has been inserted. }
} }
$this->subject(str_replace("<br>", "", $this->build_email->getSubject())) $this->subject(str_replace("<br>", "", $this->build_email->getSubject()))

View File

@ -11,10 +11,11 @@
namespace App\Mail; namespace App\Mail;
use App\Utils\Ninja;
use App\Models\VendorContact; use App\Models\VendorContact;
use App\Services\PdfMaker\Designs\Utilities\DesignHelpers;
use App\Utils\VendorHtmlEngine;
use Illuminate\Mail\Mailable; use Illuminate\Mail\Mailable;
use App\Utils\VendorHtmlEngine;
use App\Services\PdfMaker\Designs\Utilities\DesignHelpers;
class VendorTemplateEmail extends Mailable class VendorTemplateEmail extends Mailable
{ {
@ -102,8 +103,19 @@ class VendorTemplateEmail extends Mailable
$this->from(config('mail.from.address'), $email_from_name); $this->from(config('mail.from.address'), $email_from_name);
if (strlen($settings->bcc_email) > 1) { if (strlen($settings->bcc_email) > 1) {
if (Ninja::isHosted()) {
if($this->company->account->isPaid()) {
$bccs = explode(',', str_replace(' ', '', $settings->bcc_email));
$this->bcc(array_slice($bccs, 0, 5));
}
} else {
$this->bcc(explode(',', str_replace(' ', '', $settings->bcc_email))); $this->bcc(explode(',', str_replace(' ', '', $settings->bcc_email)));
}//remove whitespace if any has been inserted. }
}
$this->subject($this->build_email->getSubject()) $this->subject($this->build_email->getSubject())
->text('email.template.text', [ ->text('email.template.text', [

View File

@ -73,7 +73,8 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
* @property int|null $deleted_at * @property int|null $deleted_at
* @property string|null $oauth_user_refresh_token * @property string|null $oauth_user_refresh_token
* @property string|null $last_confirmed_email_address * @property string|null $last_confirmed_email_address
* @property int $has_password * @property bool $has_password
* @property bool $user_logged_in_notification
* @property Carbon|null $oauth_user_token_expiry * @property Carbon|null $oauth_user_token_expiry
* @property string|null $sms_verification_code * @property string|null $sms_verification_code
* @property bool $verified_phone_number * @property bool $verified_phone_number
@ -140,6 +141,7 @@ class User extends Authenticatable implements MustVerifyEmail
* *
*/ */
protected $fillable = [ protected $fillable = [
'user_logged_in_notification',
'first_name', 'first_name',
'last_name', 'last_name',
'email', 'email',

View File

@ -140,7 +140,7 @@ class Email implements ShouldQueue
$this->email_object->client_id ? $this->email_object->settings = $this->email_object->client->getMergedSettings() : $this->email_object->settings = $this->company->settings; $this->email_object->client_id ? $this->email_object->settings = $this->email_object->client->getMergedSettings() : $this->email_object->settings = $this->company->settings;
$this->email_object->client_id ? nlog("client settings") : nlog("company settings "); // $this->email_object->client_id ? nlog("client settings") : nlog("company settings ");
$this->email_object->whitelabel = $this->company->account->isPaid() ? true : false; $this->email_object->whitelabel = $this->company->account->isPaid() ? true : false;
@ -418,6 +418,9 @@ class Email implements ShouldQueue
return true; return true;
} }
if($address_object->name == " " || $address_object->name == "") {
return true;
}
} }

View File

@ -255,8 +255,8 @@ class EmailDefaults
if (strlen($this->email->email_object->settings->bcc_email) > 1) { if (strlen($this->email->email_object->settings->bcc_email) > 1) {
if (Ninja::isHosted() && $this->email->company->account->isPaid()) { if (Ninja::isHosted() && $this->email->company->account->isPaid()) {
$bccs = array_slice(explode(',', str_replace(' ', '', $this->email->email_object->settings->bcc_email)), 0, 2); $bccs = array_slice(explode(',', str_replace(' ', '', $this->email->email_object->settings->bcc_email)), 0, 5);
} elseif (Ninja::isSelfHost()) { } else {
$bccs = (explode(',', str_replace(' ', '', $this->email->email_object->settings->bcc_email))); $bccs = (explode(',', str_replace(' ', '', $this->email->email_object->settings->bcc_email)));
} }
} }

View File

@ -64,6 +64,7 @@ class UserTransformer extends EntityTransformer
'oauth_user_token' => empty($user->oauth_user_token) ? '' : '***', 'oauth_user_token' => empty($user->oauth_user_token) ? '' : '***',
'verified_phone_number' => (bool) $user->verified_phone_number, 'verified_phone_number' => (bool) $user->verified_phone_number,
'language_id' => (string) $user->language_id ?? '', 'language_id' => (string) $user->language_id ?? '',
'user_logged_in_notification' => (bool) $user->user_logged_in_notification,
]; ];
} }

View File

@ -0,0 +1,43 @@
<?php
use App\Models\Currency;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('user_logged_in_notification')->default(true);
});
$cur = Currency::find(120);
if(!$cur) {
$cur = new \App\Models\Currency();
$cur->id = 120;
$cur->code = 'TOP';
$cur->name = "Tongan Pa'anga";
$cur->symbol = 'T$';
$cur->thousand_separator = ',';
$cur->decimal_separator = '.';
$cur->precision = 2;
$cur->save();
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};

View File

@ -142,6 +142,7 @@ class CurrenciesSeeder extends Seeder
['id' => 117, 'name' => 'Gold Troy Ounce', 'code' => 'XAU', 'symbol' => 'XAU', 'precision' => '3', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 117, 'name' => 'Gold Troy Ounce', 'code' => 'XAU', 'symbol' => 'XAU', 'precision' => '3', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 118, 'name' => 'Nicaraguan Córdoba', 'code' => 'NIO', 'symbol' => 'C$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 118, 'name' => 'Nicaraguan Córdoba', 'code' => 'NIO', 'symbol' => 'C$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 119, 'name' => 'Malagasy ariary', 'code' => 'MGA', 'symbol' => 'Ar', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['id' => 119, 'name' => 'Malagasy ariary', 'code' => 'MGA', 'symbol' => 'Ar', 'precision' => '0', 'thousand_separator' => ',', 'decimal_separator' => '.'],
['id' => 120, 'name' => "Tongan Pa anga", 'code' => 'TOP', 'symbol' => 'T$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'],
]; ];
foreach ($currencies as $currency) { foreach ($currencies as $currency) {

View File

@ -2402,6 +2402,9 @@ $LANG = array(
'currency_libyan_dinar' => 'Libyan Dinar', 'currency_libyan_dinar' => 'Libyan Dinar',
'currency_silver_troy_ounce' => 'Silver Troy Ounce', 'currency_silver_troy_ounce' => 'Silver Troy Ounce',
'currency_gold_troy_ounce' => 'Gold Troy Ounce', 'currency_gold_troy_ounce' => 'Gold Troy Ounce',
'currency_nicaraguan_córdoba' => 'Nicaraguan Córdoba',
'currency_malagasy_ariary' => 'Malagasy ariary',
"currency_tongan_pa_anga" => "Tongan Pa'anga",
'review_app_help' => 'We hope you\'re enjoying using the app.<br/>If you\'d consider :link we\'d greatly appreciate it!', 'review_app_help' => 'We hope you\'re enjoying using the app.<br/>If you\'d consider :link we\'d greatly appreciate it!',
'writing_a_review' => 'writing a review', 'writing_a_review' => 'writing a review',

View File

@ -64,7 +64,7 @@
{{ ctrans('texts.public_notes') }} {{ ctrans('texts.public_notes') }}
</dt> </dt>
<dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2"> <dd class="mt-1 text-sm leading-5 text-gray-900 sm:mt-0 sm:col-span-2">
{{ $invoice->public_notes }} {!! html_entity_decode($invoice->public_notes) !!}
</dd> </dd>
@else @else
<dt class="text-sm font-medium leading-5 text-gray-500"> <dt class="text-sm font-medium leading-5 text-gray-500">