Don't send notifications when within maintenance window. Fixes #2720

This commit is contained in:
James Brooks
2017-09-14 19:02:34 +01:00
committed by Nico Stapelbroek
parent 8485821491
commit f53f88f950
6 changed files with 79 additions and 4 deletions
@@ -12,12 +12,20 @@
namespace CachetHQ\Cachet\Bus\Handlers\Events\Component;
use CachetHQ\Cachet\Bus\Events\Component\ComponentStatusWasChangedEvent;
use CachetHQ\Cachet\Integrations\Contracts\System;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Cachet\Notifications\Component\ComponentStatusChangedNotification;
class SendComponentUpdateEmailNotificationHandler
{
/**
* The system instance.
*
* @var \CachetHQ\Cachet\Integrations\Contracts\System
*/
protected $system;
/**
* The subscriber instance.
*
@@ -32,8 +40,9 @@ class SendComponentUpdateEmailNotificationHandler
*
* @return void
*/
public function __construct(Subscriber $subscriber)
public function __construct(System $system, Subscriber $subscriber)
{
$this->system = $system;
$this->subscriber = $subscriber;
}
@@ -46,6 +55,11 @@ class SendComponentUpdateEmailNotificationHandler
*/
public function handle(ComponentStatusWasChangedEvent $event)
{
// Don't send component status updates if we're under maintenance.
if ($this->system->underMaintenance()) {
return false;
}
$component = $event->component;
// If we're silent, then don't send this.