diff --git a/app/Handlers/Commands/Incident/ReportMaintenanceCommandHandler.php b/app/Handlers/Commands/Incident/ReportMaintenanceCommandHandler.php index 9fe832b7..b5842f55 100644 --- a/app/Handlers/Commands/Incident/ReportMaintenanceCommandHandler.php +++ b/app/Handlers/Commands/Incident/ReportMaintenanceCommandHandler.php @@ -41,9 +41,7 @@ class ReportMaintenanceCommandHandler ]); // Notify subscribers. - if ($command->notify) { - event(new MaintenanceWasScheduledEvent($maintenanceEvent)); - } + event(new MaintenanceWasScheduledEvent($maintenanceEvent)); return $maintenanceEvent; } diff --git a/app/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php b/app/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php index 015c984a..dc3af1ca 100644 --- a/app/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php +++ b/app/Handlers/Commands/Incident/UpdateIncidentCommandHandler.php @@ -50,9 +50,7 @@ class UpdateIncidentCommandHandler } // Notify subscribers. - if ($command->notify) { - event(new IncidentWasUpdatedEvent($incident)); - } + event(new IncidentWasUpdatedEvent($incident)); return $incident; } diff --git a/app/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php b/app/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php index 69b88ddb..a5f09cbd 100644 --- a/app/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php +++ b/app/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php @@ -56,6 +56,10 @@ class SendIncidentEmailNotificationHandler */ public function handle(IncidentWasReportedEvent $event) { + if (!$event->incident->notify) { + return false; + } + $incident = AutoPresenter::decorate($event->incident); $component = AutoPresenter::decorate($event->incident->component); diff --git a/app/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php b/app/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php index 8ce7e087..d942979e 100644 --- a/app/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php +++ b/app/Handlers/Events/Incident/SendMaintenanceEmailNotificationHandler.php @@ -56,6 +56,10 @@ class SendMaintenanceEmailNotificationHandler */ public function handle(MaintenanceWasScheduledEvent $event) { + if (!$event->incident->notify) { + return false; + } + $data = AutoPresenter::decorate($event->incident); foreach ($this->subscriber->all() as $subscriber) {