diff --git a/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php b/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php
index caa65a757975..de230a977f24 100644
--- a/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php
+++ b/app/Bus/Commands/IncidentUpdate/CreateIncidentUpdateCommand.php
@@ -54,6 +54,14 @@ final class CreateIncidentUpdateCommand
* @var int
*/
public $component_status;
+
+ /**
+ * Whether to notify about the update or not.
+ *
+ * @var bool
+ */
+ public $notify;
+
/**
* The user.
*
@@ -72,6 +80,7 @@ final class CreateIncidentUpdateCommand
'message' => 'required|string',
'component_id' => 'nullable|required_with:component_status|int',
'component_status' => 'nullable|required_with:component_id|int|min:0|max:4',
+ 'notify' => 'nullable|bool',
'user' => 'required',
];
@@ -85,13 +94,14 @@ final class CreateIncidentUpdateCommand
*
* @return void
*/
- public function __construct(Incident $incident, $status, $message, $component_id, $component_status, User $user)
+ public function __construct(Incident $incident, $status, $message, $component_id, $component_status, $notify, User $user)
{
$this->incident = $incident;
$this->status = $status;
$this->message = $message;
$this->component_id = $component_id;
$this->component_status = $component_status;
+ $this->notify = $notify;
$this->user = $user;
}
}
diff --git a/app/Bus/Events/IncidentUpdate/IncidentUpdateWasReportedEvent.php b/app/Bus/Events/IncidentUpdate/IncidentUpdateWasReportedEvent.php
index 52dadf881029..77f51ab9ab50 100644
--- a/app/Bus/Events/IncidentUpdate/IncidentUpdateWasReportedEvent.php
+++ b/app/Bus/Events/IncidentUpdate/IncidentUpdateWasReportedEvent.php
@@ -36,18 +36,27 @@ final class IncidentUpdateWasReportedEvent implements ActionInterface, IncidentU
*/
public $update;
+ /**
+ * Whether to notify about the incident update or not.
+ *
+ * @var bool
+ */
+ public $notify;
+
/**
* Create a new incident update was reported event instance.
*
* @param \CachetHQ\Cachet\Models\User $user
* @param \CachetHQ\Cachet\Models\IncidentUpdate $update
+ * @param bool $notify
*
* @return void
*/
- public function __construct(User $user, IncidentUpdate $update)
+ public function __construct(User $user, IncidentUpdate $update, $notify = false)
{
$this->user = $user;
$this->update = $update;
+ $this->notify = $notify;
}
/**
diff --git a/app/Bus/Handlers/Commands/IncidentUpdate/CreateIncidentUpdateCommandHandler.php b/app/Bus/Handlers/Commands/IncidentUpdate/CreateIncidentUpdateCommandHandler.php
index 20dd2c84a933..b244fc1c7fea 100644
--- a/app/Bus/Handlers/Commands/IncidentUpdate/CreateIncidentUpdateCommandHandler.php
+++ b/app/Bus/Handlers/Commands/IncidentUpdate/CreateIncidentUpdateCommandHandler.php
@@ -78,7 +78,7 @@ public function handle(CreateIncidentUpdateCommand $command)
[]
));
- event(new IncidentUpdateWasReportedEvent($this->auth->user(), $update));
+ event(new IncidentUpdateWasReportedEvent($this->auth->user(), $update, $command->notify));
return $update;
}
diff --git a/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php b/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php
index 6ecdbfca3a0f..131c4f19f9bc 100644
--- a/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php
+++ b/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php
@@ -58,7 +58,7 @@ public function handle(ComponentStatusWasChangedEvent $event)
$component = $event->component;
// If we're silent or the notifications are suppressed don't send this.
- if ($event->silent || !$this->system->canNotifySubscribers()) {
+ if ($event->silent || !$this->system->canNotifySubscribers() || $this->system->shouldDisableNotifications()) {
return;
}
diff --git a/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php b/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php
index d30916d10de3..26d7b9ff480c 100644
--- a/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php
+++ b/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php
@@ -58,7 +58,7 @@ public function handle(IncidentWasCreatedEvent $event)
$incident = $event->incident;
if (!$event->notify || !$this->system->canNotifySubscribers()) {
- return false;
+ return;
}
// Only send emails for public incidents.
diff --git a/app/Bus/Handlers/Events/IncidentUpdate/SendIncidentUpdateEmailNotificationHandler.php b/app/Bus/Handlers/Events/IncidentUpdate/SendIncidentUpdateEmailNotificationHandler.php
index 447604816e4d..df7f4e6ee231 100644
--- a/app/Bus/Handlers/Events/IncidentUpdate/SendIncidentUpdateEmailNotificationHandler.php
+++ b/app/Bus/Handlers/Events/IncidentUpdate/SendIncidentUpdateEmailNotificationHandler.php
@@ -55,6 +55,10 @@ public function __construct(System $system, Subscriber $subscriber)
*/
public function handle(IncidentUpdateWasReportedEvent $event)
{
+ if (!$event->notify || !$this->system->canNotifySubscribers()) {
+ return;
+ }
+
$update = $event->update;
$incident = $update->incident;
diff --git a/app/Http/Controllers/Dashboard/DashboardController.php b/app/Http/Controllers/Dashboard/DashboardController.php
index 1c0cfea65c4e..ff6c9822df99 100644
--- a/app/Http/Controllers/Dashboard/DashboardController.php
+++ b/app/Http/Controllers/Dashboard/DashboardController.php
@@ -12,6 +12,7 @@
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
use CachetHQ\Cachet\Bus\Commands\User\WelcomeUserCommand;
+use CachetHQ\Cachet\Integrations\Contracts\System;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident;
@@ -51,18 +52,27 @@ class DashboardController extends Controller
*/
protected $guard;
+ /**
+ * The system instance.
+ *
+ * @var \CachetHQ\Cachet\Integrations\Contracts\System
+ */
+ protected $system;
+
/**
* Creates a new dashboard controller instance.
*
- * @param \Illuminate\Contracts\Auth\Guard $guard
+ * @param \Illuminate\Contracts\Auth\Guard $guard
+ * @param \CachetHQ\Cachet\Integrations\Contracts\System $system
*
* @return void
*/
- public function __construct(Guard $guard)
+ public function __construct(Guard $guard, System $system)
{
$this->guard = $guard;
$this->startDate = new Date();
$this->dateTimeZone = Config::get('cachet.timezone');
+ $this->system = $system;
}
/**
@@ -101,7 +111,8 @@ public function showDashboard()
->withSubscribers($subscribers)
->withComponentGroups($componentGroups)
->withUngroupedComponents($ungroupedComponents)
- ->withWelcomeUser($welcomeUser);
+ ->withWelcomeUser($welcomeUser)
+ ->withNoNotifications($this->system->shouldDisableNotifications());
}
/**
diff --git a/app/Http/Controllers/Dashboard/IncidentController.php b/app/Http/Controllers/Dashboard/IncidentController.php
index f5555aa0bb9c..447a849a29e0 100644
--- a/app/Http/Controllers/Dashboard/IncidentController.php
+++ b/app/Http/Controllers/Dashboard/IncidentController.php
@@ -94,6 +94,7 @@ public function showAddIncident()
->withComponentsInGroups(ComponentGroup::with('components')->get())
->withComponentsOutGroups(Component::where('group_id', '=', 0)->get())
->withNotificationsEnabled($this->system->canNotifySubscribers())
+ ->withNoNotifications($this->system->shouldDisableNotifications())
->withIncidentTemplates(IncidentTemplate::all());
}
@@ -233,8 +234,7 @@ public function showEditIncidentAction(Incident $incident)
->withPageTitle(trans('dashboard.incidents.edit.title').' - '.trans('dashboard.dashboard'))
->withIncident($incident)
->withComponentsInGroups(ComponentGroup::with('components')->get())
- ->withComponentsOutGroups(Component::where('group_id', '=', 0)->get())
- ->withNotificationsEnabled($this->system->canNotifySubscribers());
+ ->withComponentsOutGroups(Component::where('group_id', '=', 0)->get());
}
/**
diff --git a/app/Http/Controllers/Dashboard/IncidentUpdateController.php b/app/Http/Controllers/Dashboard/IncidentUpdateController.php
index 092809e374dc..aac4da276678 100644
--- a/app/Http/Controllers/Dashboard/IncidentUpdateController.php
+++ b/app/Http/Controllers/Dashboard/IncidentUpdateController.php
@@ -109,6 +109,7 @@ public function createIncidentUpdateAction(Incident $incident)
Binput::get('message'),
Binput::get('component_id'),
Binput::get('component_status'),
+ Binput::get('notify'),
$this->auth->user()
));
} catch (ValidationException $e) {
diff --git a/app/Integrations/Contracts/System.php b/app/Integrations/Contracts/System.php
index a064e71065f1..c2c6c01c161f 100644
--- a/app/Integrations/Contracts/System.php
+++ b/app/Integrations/Contracts/System.php
@@ -32,6 +32,13 @@ public function getStatus();
*/
public function canNotifySubscribers();
+ /**
+ * Determine if Cachet should disable by default the checkbox to notify subscribers.
+ *
+ * @return bool
+ */
+ public function shouldDisableNotifications();
+
/**
* Get the cachet version.
*
diff --git a/app/Integrations/Core/System.php b/app/Integrations/Core/System.php
index b1f7183c1e70..2332f5cb97e8 100644
--- a/app/Integrations/Core/System.php
+++ b/app/Integrations/Core/System.php
@@ -110,13 +110,23 @@ public function getStatus()
* @return bool
*/
public function canNotifySubscribers()
+ {
+ return $this->config->get('setting.enable_notifications');
+ }
+
+ /**
+ * Determine if Cachet should disable by default the checkbox to notify subscribers.
+ *
+ * @return bool
+ */
+ public function shouldDisableNotifications()
{
$maintenancePeriods = Schedule::inProgress()->count();
if ($maintenancePeriods === 0) {
- return true;
+ return false;
}
- return !$this->config->get('setting.suppress_notifications_in_maintenance');
+ return $this->config->get('setting.disable_notifications_in_maintenance');
}
/**
diff --git a/config/setting.php b/config/setting.php
index d7917b33e90e..9eac6496b878 100644
--- a/config/setting.php
+++ b/config/setting.php
@@ -38,12 +38,12 @@
| Suppress notifications while in maintenance
|--------------------------------------------------------------------------
|
- | Whether to suppress notification channels if an issue is created during
+ | Whether to disable by default notifications if an issue is created during
| planned or in-progress maintenance periods.
|
*/
- 'suppress_notifications_in_maintenance' => true,
+ 'disable_notifications_in_maintenance' => true,
/*
|--------------------------------------------------------------------------
diff --git a/resources/lang/en/dashboard.php b/resources/lang/en/dashboard.php
index a72689a5a623..612788c94545 100644
--- a/resources/lang/en/dashboard.php
+++ b/resources/lang/en/dashboard.php
@@ -13,6 +13,7 @@
'dashboard' => 'Dashboard',
'writeable_settings' => 'The Cachet settings directory is not writeable. Please make sure that ./bootstrap/cachet is writeable by the web server.',
+ 'notify_disabled' => 'Due to scheduled maintenance, notifications about status updates of components are disabled.',
// Incidents
'incidents' => [
diff --git a/resources/lang/en/forms.php b/resources/lang/en/forms.php
index 5c5a41a9c5d5..1cf6b4a27771 100644
--- a/resources/lang/en/forms.php
+++ b/resources/lang/en/forms.php
@@ -54,7 +54,7 @@
'message-help' => 'You may also use Markdown.',
'occurred_at' => 'When did this incident occur?',
'notify_subscribers' => 'Notify subscribers?',
- 'notify_disabled' => 'Due to scheduled maintenance, notifications about this incident or its components will be suppressed.',
+ 'notify_disabled' => 'Due to scheduled maintenance, notifications about this incident or its components are disabled by default.',
'visibility' => 'Incident Visibility',
'stick_status' => 'Stick Incident',
'stickied' => 'Stickied',
@@ -148,22 +148,23 @@
'settings' => [
// Application setup
'app-setup' => [
- 'site-name' => 'Site Name',
- 'site-url' => 'Site URL',
- 'display-graphs' => 'Display graphs on status page?',
- 'about-this-page' => 'About this page',
- 'days-of-incidents' => 'How many days of incidents to show?',
- 'time_before_refresh' => 'Status page refresh rate (in seconds)',
- 'major_outage_rate' => 'Major outage threshold (in %)',
- 'banner' => 'Banner Image',
- 'banner-help' => "It's recommended that you upload files no bigger than 930px wide",
- 'subscribers' => 'Allow people to signup to email notifications?',
- 'suppress_notifications_in_maintenance' => 'Suppress notifications when incident occurs during maintenance period?',
- 'skip_subscriber_verification' => 'Skip verifying of users? (Be warned, you could be spammed)',
- 'automatic_localization' => 'Automatically localise your status page to your visitor\'s language?',
- 'enable_external_dependencies' => 'Enable Third Party Dependencies (Google Fonts, Trackers, etc...)',
- 'show_timezone' => 'Show the timezone the status page is running in',
- 'only_disrupted_days' => 'Only show days containing incidents in the timeline?',
+ 'site-name' => 'Site Name',
+ 'site-url' => 'Site URL',
+ 'display-graphs' => 'Display graphs on status page?',
+ 'about-this-page' => 'About this page',
+ 'days-of-incidents' => 'How many days of incidents to show?',
+ 'time_before_refresh' => 'Status page refresh rate (in seconds)',
+ 'major_outage_rate' => 'Major outage threshold (in %)',
+ 'banner' => 'Banner Image',
+ 'banner-help' => "It's recommended that you upload files no bigger than 930px wide",
+ 'subscribers' => 'Allow people to signup to email notifications?',
+ 'enable_notifications' => 'Enable notifications?',
+ 'disable_notifications_in_maintenance' => 'Disable notifications by default when incident occurs during maintenance period?',
+ 'skip_subscriber_verification' => 'Skip verifying of users? (Be warned, you could be spammed)',
+ 'automatic_localization' => 'Automatically localise your status page to your visitor\'s language?',
+ 'enable_external_dependencies' => 'Enable Third Party Dependencies (Google Fonts, Trackers, etc...)',
+ 'show_timezone' => 'Show the timezone the status page is running in',
+ 'only_disrupted_days' => 'Only show days containing incidents in the timeline?',
],
'analytics' => [
'analytics_google' => 'Google Analytics code',
diff --git a/resources/views/dashboard/incidents/add.blade.php b/resources/views/dashboard/incidents/add.blade.php
index 421013bcf6c7..9cdf05706e0b 100644
--- a/resources/views/dashboard/incidents/add.blade.php
+++ b/resources/views/dashboard/incidents/add.blade.php
@@ -13,7 +13,7 @@