mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 12:14:37 -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)
|
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->send_email = false;
|
||||||
$invite->contact->save();
|
$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->send_email = false;
|
||||||
$invite->contact->save();
|
$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->send_email = false;
|
||||||
$invite->contact->save();
|
$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);
|
return $this->render('generic.unsubscribe', $data);
|
||||||
|
|
||||||
|
@ -97,6 +97,7 @@ class TemplateEmail extends Mailable
|
|||||||
'footer' => $this->build_email->getFooter(),
|
'footer' => $this->build_email->getFooter(),
|
||||||
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
|
'unsubscribe_link' => $this->invitation->getUnsubscribeLink(),
|
||||||
])
|
])
|
||||||
->view($template_name, [
|
->view($template_name, [
|
||||||
'greeting' => ctrans('texts.email_salutation', ['name' => $this->contact->present()->name()]),
|
'greeting' => ctrans('texts.email_salutation', ['name' => $this->contact->present()->name()]),
|
||||||
@ -110,6 +111,7 @@ class TemplateEmail extends Mailable
|
|||||||
'company' => $company,
|
'company' => $company,
|
||||||
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
'whitelabel' => $this->client->user->account->isPaid() ? true : false,
|
||||||
'logo' => $this->company->present()->logo($settings),
|
'logo' => $this->company->present()->logo($settings),
|
||||||
|
'unsubscribe_link' => $this->invitation->getUnsubscribeLink(),
|
||||||
])
|
])
|
||||||
->withSwiftMessage(function ($message) use($company){
|
->withSwiftMessage(function ($message) use($company){
|
||||||
$message->getHeaders()->addTextHeader('Tag', $company->company_key);
|
$message->getHeaders()->addTextHeader('Tag', $company->company_key);
|
||||||
|
@ -54,6 +54,18 @@ trait Inviteable
|
|||||||
return $domain.'/client/pay/'.$this->key;
|
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
|
public function getLink() :string
|
||||||
{
|
{
|
||||||
$entity_type = Str::snake(class_basename($this->entityType()));
|
$entity_type = Str::snake(class_basename($this->entityType()));
|
||||||
|
@ -4545,8 +4545,9 @@ $LANG = array(
|
|||||||
'activity_124' => ':user restored recurring expense :recurring_expense',
|
'activity_124' => ':user restored recurring expense :recurring_expense',
|
||||||
'fpx' => "FPX",
|
'fpx' => "FPX",
|
||||||
'to_view_entity_set_password' => 'To view the :entity you need to set password.',
|
'to_view_entity_set_password' => 'To view the :entity you need to set password.',
|
||||||
|
'unsubscribe' => 'Unsubscribe',
|
||||||
'unsubscribed' => 'Unsubscribed',
|
'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;
|
return $LANG;
|
||||||
|
@ -177,6 +177,9 @@
|
|||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
@if(isset($unsubscribe_link))
|
||||||
|
<p><a href="{{$unsubscribe_link}}">{{ ctrans('texts.unsubscribe') }}</a></p>
|
||||||
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -29,3 +29,6 @@
|
|||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
@endisset
|
@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