diff --git a/app/Handlers/Events/SendIncidentEmailNotificationHandler.php b/app/Handlers/Events/SendIncidentEmailNotificationHandler.php index 16747504..8c23de4e 100644 --- a/app/Handlers/Events/SendIncidentEmailNotificationHandler.php +++ b/app/Handlers/Events/SendIncidentEmailNotificationHandler.php @@ -67,23 +67,27 @@ class SendIncidentEmailNotificationHandler { $data = $this->presenter->decorate($event->incident); - foreach ($this->subscriber->all() as $subscriber) { - $mail = [ - 'email' => $subscriber->email, - 'subject' => 'New incident reported.', - 'status' => $data->humanStatus, - 'htmlContent' => $data->formattedMessage, - 'textContent' => $data->message, - 'token' => $subscriber->token, - 'unsubscribeLink' => route('unsubscribe', ['code' => $subscriber->token]), - ]; + // Only send emails for public incidents. + if ($event->incident->visible === 1) { + foreach ($this->subscriber->all() as $subscriber) { + $mail = [ + 'email' => $subscriber->email, + 'subject' => 'New incident reported.', + 'status' => $data->humanStatus, + 'htmlContent' => $data->formattedMessage, + 'textContent' => $data->message, + 'token' => $subscriber->token, + 'unsubscribeLink' => route('unsubscribe', ['code' => $subscriber->token]), + 'appUrl' => env('APP_URL'), + ]; - $this->mailer->queue([ - 'html' => 'emails.incidents.new-html', - 'text' => 'emails.incidents.new-text', - ], $mail, function (Message $message) use ($mail) { - $message->to($mail['email'])->subject($mail['subject']); - }); + $this->mailer->queue([ + 'html' => 'emails.incidents.new-html', + 'text' => 'emails.incidents.new-text', + ], $mail, function (Message $message) use ($mail) { + $message->to($mail['email'])->subject($mail['subject']); + }); + } } } } diff --git a/app/Handlers/Events/SendMaintenanceEmailNotificationHandler.php b/app/Handlers/Events/SendMaintenanceEmailNotificationHandler.php index c2642090..9222e850 100644 --- a/app/Handlers/Events/SendMaintenanceEmailNotificationHandler.php +++ b/app/Handlers/Events/SendMaintenanceEmailNotificationHandler.php @@ -76,6 +76,7 @@ class SendMaintenanceEmailNotificationHandler 'textContent' => $data->message, 'token' => $subscriber->token, 'unsubscribeLink' => route('unsubscribe', ['code' => $subscriber->token]), + 'appUrl' => env('APP_URL'), ]; $this->mailer->queue([ diff --git a/app/Handlers/Events/SendSubscriberVerificationEmailHandler.php b/app/Handlers/Events/SendSubscriberVerificationEmailHandler.php index 90fe12ab..1cc006c3 100644 --- a/app/Handlers/Events/SendSubscriberVerificationEmailHandler.php +++ b/app/Handlers/Events/SendSubscriberVerificationEmailHandler.php @@ -49,6 +49,7 @@ class SendSubscriberVerificationEmailHandler 'email' => $event->subscriber->email, 'subject' => 'Confirm your subscription.', 'link' => route('subscribe-verify', ['code' => $event->subscriber->verify_code]), + 'appUrl' => env('APP_URL'), ]; $this->mailer->queue([