From e51504b3ec1041b9f2b1e5e4dc364b1dee9c4dde Mon Sep 17 00:00:00 2001
From: Joseph Cohen
Date: Sat, 20 Feb 2016 12:23:06 -0600
Subject: [PATCH] Add manage link to email notifications
---
...omponentUpdateEmailNotificationHandler.php | 1 +
.../SendIncidentEmailNotificationHandler.php | 1 +
...endMaintenanceEmailNotificationHandler.php | 1 +
app/Http/Controllers/SubscribeController.php | 6 ++-
app/Http/Routes/SubscribeRoutes.php | 4 +-
resources/lang/en/cachet.php | 1 +
.../emails/components/update-html.blade.php | 3 ++
.../emails/components/update-text.blade.php | 2 +
.../incidents/maintenance-html.blade.php | 31 +++++++++-------
.../incidents/maintenance-text.blade.php | 2 +
.../views/emails/incidents/new-html.blade.php | 37 ++++++++++---------
.../views/emails/incidents/new-text.blade.php | 2 +
12 files changed, 56 insertions(+), 35 deletions(-)
diff --git a/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php b/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php
index 80f88e3b..695b351a 100644
--- a/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php
+++ b/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php
@@ -59,6 +59,7 @@ class SendComponentUpdateEmailNotificationHandler
foreach (Subscription::isVerifiedForComponent($component->id)->with('subscriber')->get() as $subscription) {
$subscriber = $subscription->subscriber;
$mail['email'] = $subscriber->email;
+ $mail['manage_link'] = route('subscribe.manage', ['code' => $subscriber->verify_code]);
$mail['unsubscribe_link'] = route('subscribe.unsubscribe', ['code' => $subscriber->verify_code, 'subscription' => $subscription->id]);
$this->mailer->queue([
diff --git a/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php b/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php
index cae51b33..177b910a 100644
--- a/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php
+++ b/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php
@@ -75,6 +75,7 @@ class SendIncidentEmailNotificationHandler
'html_content' => $incident->formattedMessage,
'text_content' => $incident->message,
'token' => $subscriber->token,
+ 'manage_link' => route('subscribe.manage', ['code' => $subscriber->verify_code]),
'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code]),
];
diff --git a/app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php b/app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php
index 54732bd2..f3e51c00 100644
--- a/app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php
+++ b/app/Bus/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php
@@ -71,6 +71,7 @@ class SendMaintenanceEmailNotificationHandler
'text_content' => $data->message,
'scheduled_at' => $data->scheduled_at_formatted,
'token' => $subscriber->token,
+ 'manage_link' => route('subscribe.manage', ['code' => $subscriber->verify_code]),
'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code]),
];
diff --git a/app/Http/Controllers/SubscribeController.php b/app/Http/Controllers/SubscribeController.php
index 5fcb0659..8ac61b19 100644
--- a/app/Http/Controllers/SubscribeController.php
+++ b/app/Http/Controllers/SubscribeController.php
@@ -131,11 +131,13 @@ class SubscribeController extends Controller
/**
* Shows the subscription manager page.
*
+ * @param string|null $code
+ *
* @return \Illuminate\View\View
*/
- public function showManage()
+ public function showManage($code = null)
{
- if (!($code = Binput::get('subscriber'))) {
+ if ($code === null) {
throw new NotFoundHttpException();
}
diff --git a/app/Http/Routes/SubscribeRoutes.php b/app/Http/Routes/SubscribeRoutes.php
index b7a373c4..b4eb0b90 100644
--- a/app/Http/Routes/SubscribeRoutes.php
+++ b/app/Http/Routes/SubscribeRoutes.php
@@ -39,8 +39,8 @@ class SubscribeRoutes
'uses' => 'SubscribeController@postSubscribe',
]);
- $router->get('subscribe/manage', [
- 'as' => 'subscribe.manage',
+ $router->get('subscribe/manage/{code}', [
+ 'as' => 'manage',
'uses' => 'SubscribeController@showManage',
]);
diff --git a/resources/lang/en/cachet.php b/resources/lang/en/cachet.php
index 50b6f17f..2f3a780b 100755
--- a/resources/lang/en/cachet.php
+++ b/resources/lang/en/cachet.php
@@ -71,6 +71,7 @@ return [
'subscribe' => 'Subscribe to email updates.',
'subscribed' => 'You\'ve been subscribed to email notifications, please check your email to confirm your subscription.',
'verified' => 'Your email subscription has been confirmed. Thank you!',
+ 'manage' => 'Manage your subscription.',
'unsubscribe' => 'Unsubscribe from email updates.',
'unsubscribed' => 'Your email subscription has been cancelled.',
'failure' => 'Something went wrong with the subscription.',
diff --git a/resources/views/emails/components/update-html.blade.php b/resources/views/emails/components/update-html.blade.php
index f8266460..d8fb0555 100644
--- a/resources/views/emails/components/update-html.blade.php
+++ b/resources/views/emails/components/update-html.blade.php
@@ -10,6 +10,9 @@
@if($show_support)
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
@endif
+
+ {!! trans('cachet.subscriber.email.manage') !!}
+
{!! trans('cachet.subscriber.email.unsubscribe') !!}
diff --git a/resources/views/emails/components/update-text.blade.php b/resources/views/emails/components/update-text.blade.php
index 297287e4..10b880fb 100644
--- a/resources/views/emails/components/update-text.blade.php
+++ b/resources/views/emails/components/update-text.blade.php
@@ -4,4 +4,6 @@
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
@endif
+{!! trans('cachet.subscriber.email.manage') !!} {{ $manage_link }}
+
{!! trans('cachet.subscriber.email.unsubscribe') !!} {{ $unsubscribe_link }}
diff --git a/resources/views/emails/incidents/maintenance-html.blade.php b/resources/views/emails/incidents/maintenance-html.blade.php
index b734a634..3a200212 100644
--- a/resources/views/emails/incidents/maintenance-html.blade.php
+++ b/resources/views/emails/incidents/maintenance-html.blade.php
@@ -5,22 +5,25 @@
@stop
@section('content')
- {!! trans('cachet.subscriber.email.maintenance.html', ['app_name' => $app_name]) !!}
+{!! trans('cachet.subscriber.email.maintenance.html', ['app_name' => $app_name]) !!}
- {{ $scheduled_at }}
+{{ $scheduled_at }}
-
- {!! $status !!}
-
+
+ {!! $status !!}
+
-
- {!! $html_content !!}
-
+
+ {!! $html_content !!}
+
- @if($show_support)
- {!! trans('cachet.powered_by', ['app' => $app_name]) !!}
- @endif
-
- {!! trans('cachet.subscriber.email.unsubscribe') !!}
-
+@if($show_support)
+{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
+@endif
+
+ {!! trans('cachet.subscriber.email.manage') !!}
+
+
+ {!! trans('cachet.subscriber.email.unsubscribe') !!}
+
@stop
diff --git a/resources/views/emails/incidents/maintenance-text.blade.php b/resources/views/emails/incidents/maintenance-text.blade.php
index ea0346a3..81c33dfe 100644
--- a/resources/views/emails/incidents/maintenance-text.blade.php
+++ b/resources/views/emails/incidents/maintenance-text.blade.php
@@ -10,4 +10,6 @@
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
@endif
+{!! trans('cachet.subscriber.email.manage') !!} {{ $manage_link }}
+
{!! trans('cachet.subscriber.email.unsubscribe') !!} {{ $unsubscribe_link }}
diff --git a/resources/views/emails/incidents/new-html.blade.php b/resources/views/emails/incidents/new-html.blade.php
index 60d8583c..ec35fefb 100644
--- a/resources/views/emails/incidents/new-html.blade.php
+++ b/resources/views/emails/incidents/new-html.blade.php
@@ -5,23 +5,26 @@
@stop
@section('content')
- {!! trans('cachet.subscriber.email.incident.html-preheader', ['app_name' => $app_name]) !!}
+{!! trans('cachet.subscriber.email.incident.html-preheader', ['app_name' => $app_name]) !!}
-
- {!! $status !!}
- @if($has_component)
- ({{ $component_name }})
- @endif
-
-
-
- {!! $html_content !!}
-
-
- @if($show_support)
- {!! trans('cachet.powered_by', ['app' => $app_name]) !!}
+
+ {!! $status !!}
+ @if($has_component)
+ ({{ $component_name }})
@endif
-
- {!! trans('cachet.subscriber.email.unsubscribe') !!}
-
+
+
+
+ {!! $html_content !!}
+
+
+@if($show_support)
+{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
+@endif
+
+ {!! trans('cachet.subscriber.email.manage') !!}
+
+
+ {!! trans('cachet.subscriber.email.unsubscribe') !!}
+
@stop
diff --git a/resources/views/emails/incidents/new-text.blade.php b/resources/views/emails/incidents/new-text.blade.php
index 3386519d..e5d32c84 100644
--- a/resources/views/emails/incidents/new-text.blade.php
+++ b/resources/views/emails/incidents/new-text.blade.php
@@ -11,4 +11,6 @@
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
@endif
+{!! trans('cachet.subscriber.email.manage') !!} {{ $manage_link }}
+
{!! trans('cachet.subscriber.email.unsuscribe') !!} {{ $unsubscribe_link }}