Warn subscribers only when component state changes
Before submitting your issue, please make sure that you've checked the checkboxes below.
- [x] I am running the 2.3.6 version of Cachet.
- [x] I am running at least PHP 5.5.9. You can check this by running
php -v. - [x] I have ran
rm -rf bootstrap/cache/*.
Expected behaviour
I have an external component which uses the API to issue various components status updates, I think that when an API call is sent which actually does -not- change the status, subscribers should not be warned as nothing changed. I understand that I can refactor my stuff, but I still think there should be at least an optional way to disable email updates when component status is not updated, instead of whenever an API PUT is made.
Actual behaviour
Emails are sent to subscribers whenever a PUT is made to the component even if the status is the same.
Steps to reproduce
From an initial operational status, update to Major Outage (get an email), update to Operational (get an email), update to Operational again (get another email).
This is something I noticed the other day, and should definitely be changed.
Ping @joecohens.
This probably require a check of previous state before an event is fired, whereas a quick look at the code tells me that there is no comparison at all and an event is fired on any activity.
@jbrooksuk : thanks for the update, just trying the new version now, but updating a component status from the dashboard gives me the following error in the logs:
[2016-08-15 11:22:23] production.CRITICAL: Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to CachetHQ\Cachet\Bus\Handlers\Events\Component\SendComponentUpdateEmailNotificationHandler::handle() must be an instance of CachetHQ\Cachet\Bus\Events\Component\ComponentWasUpdatedEvent, instance of CachetHQ\Cachet\Bus\Events\Component\ComponentStatusWasUpdatedEvent given in /home/vcap/app/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php:58
Seems like there is a little change required in Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php to accept the new object?
Oops, it looks like it.
Would you mind making this change? :)
I've fixed this now.
Thanks! and sorry - had to focus on some other stuff afterwards.
@jbrooksuk : I bet it sends the old status instead of the new one in the email generation though :D
"The component XXX has seen a status change. The component is now at Performance Issues." just when I updated from Performance issues to Major Outage.
New issue please ;)
Sure, created #2061 ! :)