Don't fire component update emails if the status hasn't changed.

Fixes #2113
This commit is contained in:
James Brooks
2016-09-29 10:03:47 +01:00
parent 8ce7e5e82e
commit b40066b20e
2 changed files with 7 additions and 3 deletions

View File

@@ -28,10 +28,9 @@ class UpdateComponentCommandHandler
public function handle(UpdateComponentCommand $command)
{
$component = $command->component;
$originalStatus = $component->status;
if ($command->status && $component->status !== $command->status) {
event(new ComponentStatusWasUpdatedEvent($component, $component->status, $command->status));
}
event(new ComponentStatusWasUpdatedEvent($component, $originalStatus, $command->status));
$component->update($this->filter($command));

View File

@@ -59,6 +59,11 @@ class SendComponentUpdateEmailNotificationHandler
{
$component = $event->component;
// Don't email anything if the status hasn't changed.
if ($event->original_status === $event->new_status) {
return;
}
// First notify all global subscribers.
$globalSubscribers = $this->subscriber->isVerified()->isGlobal()->get();