mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add unsubscribe links to emails
This commit is contained in:
parent
d038877044
commit
9311882c23
@ -270,18 +270,20 @@ class InvitationController extends Controller
|
||||
|
||||
public function unsubscribe(Request $request, string $invitation_key)
|
||||
{
|
||||
if($invite = InvoiceInvitation::where('key', $invitation_key)->first()){
|
||||
if($invite = InvoiceInvitation::withTrashed()->where('key', $invitation_key)->first()){
|
||||
$invite->contact->send_email = false;
|
||||
$invite->contact->save();
|
||||
}elseif($invite = QuoteInvitation::where('key', $invitation_key)->first()){
|
||||
}elseif($invite = QuoteInvitation::withTrashed()->where('key', $invitation_key)->first()){
|
||||
$invite->contact->send_email = false;
|
||||
$invite->contact->save();
|
||||
}elseif($invite = CreditInvitation::where('key', $invitation_key)->first()){
|
||||
}elseif($invite = CreditInvitation::withTrashed()->where('key', $invitation_key)->first()){
|
||||
$invite->contact->send_email = false;
|
||||
$invite->contact->save();
|
||||
}
|
||||
else
|
||||
return abort(404);
|
||||
|
||||
$data['logo'] = auth()->user()->company()->present()->logo();
|
||||
$data['logo'] = $invite->company->present()->logo();
|
||||
|
||||
return $this->render('generic.unsubscribe', $data);
|
||||
|
||||
|
@ -97,6 +97,7 @@ class TemplateEmail extends Mailable
|
||||
'footer' => $this->build_email->getFooter(),
|
||||
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
||||
'settings' => $settings,
|
||||
'unsubscribe_link' => $this->invitation->getUnsubscribeLink(),
|
||||
])
|
||||
->view($template_name, [
|
||||
'greeting' => ctrans('texts.email_salutation', ['name' => $this->contact->present()->name()]),
|
||||
@ -110,6 +111,7 @@ class TemplateEmail extends Mailable
|
||||
'company' => $company,
|
||||
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
||||
'logo' => $this->company->present()->logo($settings),
|
||||
'unsubscribe_link' => $this->invitation->getUnsubscribeLink(),
|
||||
])
|
||||
->withSwiftMessage(function ($message) use($company){
|
||||
$message->getHeaders()->addTextHeader('Tag', $company->company_key);
|
||||
|
@ -54,6 +54,18 @@ trait Inviteable
|
||||
return $domain.'/client/pay/'.$this->key;
|
||||
}
|
||||
|
||||
public function getUnsubscribeLink()
|
||||
{
|
||||
if(Ninja::isHosted()){
|
||||
$domain = $this->company->domain();
|
||||
}
|
||||
else
|
||||
$domain = config('ninja.app_url');
|
||||
|
||||
return $domain.'/client/unsubscribe/'.$this->key;
|
||||
|
||||
}
|
||||
|
||||
public function getLink() :string
|
||||
{
|
||||
$entity_type = Str::snake(class_basename($this->entityType()));
|
||||
|
@ -4545,8 +4545,9 @@ $LANG = array(
|
||||
'activity_124' => ':user restored recurring expense :recurring_expense',
|
||||
'fpx' => "FPX",
|
||||
'to_view_entity_set_password' => 'To view the :entity you need to set password.',
|
||||
'unsubscribe' => 'Unsubscribe',
|
||||
'unsubscribed' => 'Unsubscribed',
|
||||
'Unsubscribed_text' => 'You have been removed from notifications for this document'
|
||||
'unsubscribed_text' => 'You have been removed from notifications for this document'
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -177,6 +177,9 @@
|
||||
</p>
|
||||
@endif
|
||||
</div>
|
||||
@if(isset($unsubscribe_link))
|
||||
<p><a href="{{$unsubscribe_link}}">{{ ctrans('texts.unsubscribe') }}</a></p>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -29,3 +29,6 @@
|
||||
</p>
|
||||
@endif
|
||||
@endisset
|
||||
@if(isset($unsubscribe_link))
|
||||
<p><a href="{{$unsubscribe_link}}">{{ ctrans('texts.unsubscribe') }}</a></p>
|
||||
@endif
|
Loading…
x
Reference in New Issue
Block a user