mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:17:32 -05:00 
			
		
		
		
	Fixes for display of unsubscribe link
This commit is contained in:
		
							parent
							
								
									31aa5eb8c9
								
							
						
					
					
						commit
						bea52e641e
					
				@ -1091,15 +1091,15 @@ class Import implements ShouldQueue
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        Invoice::unguard();
 | 
					        Invoice::unguard();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $rules = [
 | 
					        // $rules = [
 | 
				
			||||||
            '*.client_id' => ['required'],
 | 
					        //     '*.client_id' => ['required'],
 | 
				
			||||||
        ];
 | 
					        // ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $validator = Validator::make($data, $rules);
 | 
					        // // $validator = Validator::make($data, $rules);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($validator->fails()) {
 | 
					        // if ($validator->fails()) {
 | 
				
			||||||
            throw new MigrationValidatorFailed(json_encode($validator->errors()));
 | 
					        //     throw new MigrationValidatorFailed(json_encode($validator->errors()));
 | 
				
			||||||
        }
 | 
					        // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $invoice_repository = new InvoiceMigrationRepository();
 | 
					        $invoice_repository = new InvoiceMigrationRepository();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1145,6 +1145,8 @@ class Import implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            $key = "invoices_{$resource['id']}";
 | 
					            $key = "invoices_{$resource['id']}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            nlog($invoice->id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $this->ids['invoices'][$key] = [
 | 
					            $this->ids['invoices'][$key] = [
 | 
				
			||||||
                'old' => $resource['id'],
 | 
					                'old' => $resource['id'],
 | 
				
			||||||
                'new' => $invoice->id,
 | 
					                'new' => $invoice->id,
 | 
				
			||||||
@ -2056,7 +2058,7 @@ class Import implements ShouldQueue
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function failed($exception = null)
 | 
					    public function failed($exception = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        info('the job failed');
 | 
					        nlog('the job failed');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        config(['queue.failed.driver' => null]);
 | 
					        config(['queue.failed.driver' => null]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2067,11 +2069,11 @@ class Import implements ShouldQueue
 | 
				
			|||||||
        LightLogs::create($job_failure)
 | 
					        LightLogs::create($job_failure)
 | 
				
			||||||
                 ->queue();
 | 
					                 ->queue();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        info(print_r($exception->getMessage(), 1));
 | 
					        nlog(print_r($exception->getMessage(), 1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (Ninja::isHosted()) {
 | 
					        // if (Ninja::isHosted()) {
 | 
				
			||||||
            app('sentry')->captureException($exception);
 | 
					            app('sentry')->captureException($exception);
 | 
				
			||||||
        }
 | 
					        // }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -63,7 +63,6 @@ class UpdateUserLastLogin implements ShouldQueue
 | 
				
			|||||||
        $ip = array_key_exists('ip', $event->event_vars) ? $event->event_vars['ip'] : 'IP address not resolved';
 | 
					        $ip = array_key_exists('ip', $event->event_vars) ? $event->event_vars['ip'] : 'IP address not resolved';
 | 
				
			||||||
        $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)) && $user->user_logged_in_notification) {
 | 
					        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);
 | 
				
			||||||
 | 
				
			|||||||
@ -73,7 +73,8 @@ class EntityCreatedObject
 | 
				
			|||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $mail_obj->markdown = 'email.admin.generic';
 | 
					            $mail_obj->markdown = 'email.admin.generic';
 | 
				
			||||||
            
 | 
					            $mail_obj->text_view = 'email.template.text';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $content = ctrans(
 | 
					            $content = ctrans(
 | 
				
			||||||
                                    $this->template_body,
 | 
					                                    $this->template_body,
 | 
				
			||||||
                                    [
 | 
					                                    [
 | 
				
			||||||
@ -92,7 +93,7 @@ class EntityCreatedObject
 | 
				
			|||||||
                                'logo' => $this->company->present()->logo(),
 | 
					                                'logo' => $this->company->present()->logo(),
 | 
				
			||||||
                                'settings' => $this->company->settings,
 | 
					                                'settings' => $this->company->settings,
 | 
				
			||||||
                                'whitelabel' => $this->company->account->isPaid() ? true : false,
 | 
					                                'whitelabel' => $this->company->account->isPaid() ? true : false,
 | 
				
			||||||
                                'text_body' => $content,
 | 
					                                'text_body' => str_replace(['$view_button','$viewButton','$viewLink','$view_url'], '$view_url', $content),
 | 
				
			||||||
                            ];
 | 
					                            ];
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $this->entity->load('client.country', 'client.company');
 | 
					            $this->entity->load('client.country', 'client.company');
 | 
				
			||||||
@ -179,7 +180,7 @@ class EntityCreatedObject
 | 
				
			|||||||
            'logo' => $this->company->present()->logo(),
 | 
					            'logo' => $this->company->present()->logo(),
 | 
				
			||||||
            'settings' => $settings,
 | 
					            'settings' => $settings,
 | 
				
			||||||
            'whitelabel' => $this->company->account->isPaid() ? true : false,
 | 
					            'whitelabel' => $this->company->account->isPaid() ? true : false,
 | 
				
			||||||
            'text_body' => $content,
 | 
					            'text_body' => str_replace(['$view_button','$viewButton','$view_link','$view_button'], '$view_url', $content),
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -123,6 +123,15 @@ class BaseEmailEngine implements EngineInterface
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function setTextBody($text)
 | 
					    public function setTextBody($text)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (! empty($this->variables)) {
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            $text = str_replace(['$paymentLink', '$viewButton', '$view_button', '$viewLink', '$view_link'], '$view_url', $text);
 | 
				
			||||||
 | 
					            $text = str_replace(array_keys($this->variables), array_values($this->variables), $text);
 | 
				
			||||||
 | 
					            $text = str_replace(array_keys($this->variables), array_values($this->variables), $text);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->text_body = $text;
 | 
					        $this->text_body = $text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this;
 | 
					        return $this;
 | 
				
			||||||
@ -189,22 +198,4 @@ class BaseEmailEngine implements EngineInterface
 | 
				
			|||||||
        return $this->text_body;
 | 
					        return $this->text_body;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function replaceEntities($content)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $find = [
 | 
					 | 
				
			||||||
            '<p>',
 | 
					 | 
				
			||||||
            '</p>',
 | 
					 | 
				
			||||||
            '<div class="center">',
 | 
					 | 
				
			||||||
            '<\div>',
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $replace = [
 | 
					 | 
				
			||||||
            '',
 | 
					 | 
				
			||||||
            '\n\n',
 | 
					 | 
				
			||||||
            '',
 | 
					 | 
				
			||||||
            '\n\n',
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return str_replace($find, $replace, $content);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -31,6 +31,7 @@ class PaymentEmailEngine extends BaseEmailEngine
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public $client;
 | 
					    public $client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /** @var \App\Models\Payment $payment */
 | 
				
			||||||
    public $payment;
 | 
					    public $payment;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $template_data;
 | 
					    public $template_data;
 | 
				
			||||||
@ -91,6 +92,7 @@ class PaymentEmailEngine extends BaseEmailEngine
 | 
				
			|||||||
            ->setVariables($this->makeValues())
 | 
					            ->setVariables($this->makeValues())
 | 
				
			||||||
            ->setSubject($subject_template)
 | 
					            ->setSubject($subject_template)
 | 
				
			||||||
            ->setBody($body_template)
 | 
					            ->setBody($body_template)
 | 
				
			||||||
 | 
					            ->setTextBody($body_template)
 | 
				
			||||||
            ->setFooter('')
 | 
					            ->setFooter('')
 | 
				
			||||||
            ->setViewLink('')
 | 
					            ->setViewLink('')
 | 
				
			||||||
            ->setViewText('');
 | 
					            ->setViewText('');
 | 
				
			||||||
 | 
				
			|||||||
@ -12,31 +12,21 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\Mail\User;
 | 
					namespace App\Mail\User;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Illuminate\Bus\Queueable;
 | 
					use App\Models\User;
 | 
				
			||||||
 | 
					use App\Models\Company;
 | 
				
			||||||
use Illuminate\Mail\Mailable;
 | 
					use Illuminate\Mail\Mailable;
 | 
				
			||||||
use Illuminate\Queue\SerializesModels;
 | 
					 | 
				
			||||||
use Illuminate\Support\Facades\App;
 | 
					use Illuminate\Support\Facades\App;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class UserLoggedIn extends Mailable
 | 
					class UserLoggedIn extends Mailable
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    // use Queueable, SerializesModels;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public $company;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public $user;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public $ip;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Create a new message instance.
 | 
					     * Create a new message instance.
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @return void
 | 
					     * @return void
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function __construct($user, $company, $ip)
 | 
					    public function __construct(public User $user, public Company $company, public string $ip)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->company = $company;
 | 
					 | 
				
			||||||
        $this->user = $user;
 | 
					 | 
				
			||||||
        $this->ip = $ip;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@ -48,11 +38,13 @@ class UserLoggedIn extends Mailable
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        App::setLocale($this->company->getLocale());
 | 
					        App::setLocale($this->company->getLocale());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $text = ctrans('texts.new_login_description', ['email' => $this->user->email, 'ip' => $this->ip, 'time' => now()]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->from(config('mail.from.address'), config('mail.from.name'))
 | 
					        return $this->from(config('mail.from.address'), config('mail.from.name'))
 | 
				
			||||||
            ->subject(ctrans('texts.new_login_detected'))
 | 
					            ->subject(ctrans('texts.new_login_detected'))
 | 
				
			||||||
            ->text('email.admin.generic_text', [
 | 
					            ->text('email.admin.generic_text', [
 | 
				
			||||||
                'title' => ctrans('texts.new_login_detected'),
 | 
					                'title' => ctrans('texts.new_login_detected'),
 | 
				
			||||||
                'body' => strip_tags(ctrans('texts.new_login_description', ['email' => $this->user->email, 'ip' => $this->ip, 'time' => now()])),
 | 
					                'body' => $text,
 | 
				
			||||||
            ])
 | 
					            ])
 | 
				
			||||||
            ->view('email.admin.notification')
 | 
					            ->view('email.admin.notification')
 | 
				
			||||||
            ->with([
 | 
					            ->with([
 | 
				
			||||||
 | 
				
			|||||||
@ -85,13 +85,14 @@ class ClientContactRepository extends BaseRepository
 | 
				
			|||||||
            if (array_key_exists('password', $contact) && strlen($contact['password']) > 1 && strlen($update_contact->email) > 3) { //updating on a blank contact email will cause large table scanning
 | 
					            if (array_key_exists('password', $contact) && strlen($contact['password']) > 1 && strlen($update_contact->email) > 3) { //updating on a blank contact email will cause large table scanning
 | 
				
			||||||
                $update_contact->password = Hash::make($contact['password']);
 | 
					                $update_contact->password = Hash::make($contact['password']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $client->company
 | 
					                        ClientContact::withTrashed()
 | 
				
			||||||
                        ->client_contacts()
 | 
					                                    ->where('company_id', $client->id)
 | 
				
			||||||
                        ->where('email', $update_contact->email)->cursor()
 | 
					                                    ->where('client_id', $client->company_id)
 | 
				
			||||||
                                ->each(function ($saveable_contact) use ($update_contact){
 | 
					                                    ->where('email', $update_contact->email)->cursor()
 | 
				
			||||||
                                        $saveable_contact->password = $update_contact->password;
 | 
					                                            ->each(function ($saveable_contact) use ($update_contact){
 | 
				
			||||||
                                        $saveable_contact->save();
 | 
					                                                    $saveable_contact->password = $update_contact->password;
 | 
				
			||||||
                });
 | 
					                                                    $saveable_contact->save();
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (array_key_exists('email', $contact)) {
 | 
					            if (array_key_exists('email', $contact)) {
 | 
				
			||||||
 | 
				
			|||||||
@ -49,7 +49,9 @@ trait Inviteable
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function getPaymentLink()
 | 
					    public function getPaymentLink()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (Ninja::isHosted()) {
 | 
					        if (Ninja::isHosted()) {
 | 
				
			||||||
 | 
					            /**@var \App\Models\Company $company */
 | 
				
			||||||
            $domain = $this->company->domain();
 | 
					            $domain = $this->company->domain();
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $domain = config('ninja.app_url');
 | 
					            $domain = config('ninja.app_url');
 | 
				
			||||||
@ -105,7 +107,11 @@ trait Inviteable
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        switch ($this->company->portal_mode) {
 | 
					        switch ($this->company->portal_mode) {
 | 
				
			||||||
            case 'subdomain':
 | 
					            case 'subdomain':
 | 
				
			||||||
                return $domain.'/client/'.$entity_type.'/'.$this->key;
 | 
					
 | 
				
			||||||
 | 
					                if(Ninja::isHosted())
 | 
				
			||||||
 | 
					                    return 'https://router.invoiceninja.com/route/'.encrypt($domain.'/client/'.$entity_type.'/'.$this->key);
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                    return $domain.'/client/'.$entity_type.'/'.$this->key;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case 'iframe':
 | 
					            case 'iframe':
 | 
				
			||||||
                return $domain.'/client/'.$entity_type.'/'.$this->key;
 | 
					                return $domain.'/client/'.$entity_type.'/'.$this->key;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,9 +1,15 @@
 | 
				
			|||||||
{!! $title !!}
 | 
					{{ $title }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@isset($body)
 | 
					@isset($body)
 | 
				
			||||||
{!! $body !!}
 | 
					{{ strip_tags(str_replace("<br>", "\r\n", $body)) }}
 | 
				
			||||||
@endisset
 | 
					@endisset
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@isset($content)
 | 
					@isset($content)
 | 
				
			||||||
{!! $content !!}
 | 
					{{ strip_tags(str_replace("<br>", "\r\n", $content)) }}
 | 
				
			||||||
 | 
					@endisset
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@isset($whitelabel)
 | 
				
			||||||
 | 
					@if(!$whitelabel)
 | 
				
			||||||
 | 
					{{ ctrans('texts.ninja_email_footer', ['site' => 'https://invoiceninja.com']) }}
 | 
				
			||||||
 | 
					@endif
 | 
				
			||||||
@endisset
 | 
					@endisset
 | 
				
			||||||
@ -233,7 +233,7 @@
 | 
				
			|||||||
                    </td>
 | 
					                    </td>
 | 
				
			||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                @isset($email_preferences)
 | 
					                @if(isset($email_preferences) && $email_preferences)
 | 
				
			||||||
                <tr>
 | 
					                <tr>
 | 
				
			||||||
                    <td bgcolor="#242424"  cellpadding="20">
 | 
					                    <td bgcolor="#242424"  cellpadding="20">
 | 
				
			||||||
                        <div class="dark-bg-base"
 | 
					                        <div class="dark-bg-base"
 | 
				
			||||||
@ -246,7 +246,7 @@
 | 
				
			|||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </td>
 | 
					                    </td>
 | 
				
			||||||
                </tr>
 | 
					                </tr>
 | 
				
			||||||
                @endisset
 | 
					                @endif
 | 
				
			||||||
            </table>
 | 
					            </table>
 | 
				
			||||||
        </td>
 | 
					        </td>
 | 
				
			||||||
    </tr>
 | 
					    </tr>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
{!! $text_body !!}
 | 
					{{ strip_tags(str_replace("<br>", "\r\n", $text_body)) }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@isset($whitelabel)
 | 
					@isset($whitelabel)
 | 
				
			||||||
@if(!$whitelabel)
 | 
					@if(!$whitelabel)
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
{{ ctrans('texts.ninja_email_footer', ['site' => 'https://invoiceninja.com']) }}
 | 
					{{ ctrans('texts.ninja_email_footer', ['site' => 'https://invoiceninja.com']) }}
 | 
				
			||||||
@endif
 | 
					@endif
 | 
				
			||||||
@endisset
 | 
					@endisset
 | 
				
			||||||
 | 
				
			|||||||
@ -141,6 +141,15 @@ Route::group(['middleware' => ['invite_db'], 'prefix' => 'client', 'as' => 'clie
 | 
				
			|||||||
    Route::get('unsubscribe/{entity}/{invitation_key}', [App\Http\Controllers\ClientPortal\InvitationController::class, 'unsubscribe'])->name('unsubscribe');
 | 
					    Route::get('unsubscribe/{entity}/{invitation_key}', [App\Http\Controllers\ClientPortal\InvitationController::class, 'unsubscribe'])->name('unsubscribe');
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Route::get('route/{hash}', function ($hash) {
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return redirect(decrypt($hash));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Route::get('phantom/{entity}/{invitation_key}', [Phantom::class, 'displayInvitation'])->middleware(['invite_db', 'phantom_secret'])->name('phantom_view');
 | 
					Route::get('phantom/{entity}/{invitation_key}', [Phantom::class, 'displayInvitation'])->middleware(['invite_db', 'phantom_secret'])->name('phantom_view');
 | 
				
			||||||
Route::get('blade/', [Phantom::class, 'blade'])->name('blade');
 | 
					Route::get('blade/', [Phantom::class, 'blade'])->name('blade');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user