cachet icon indicating copy to clipboard operation
cachet copied to clipboard

Warn subscribers only when component state changes

Open fdhex opened this issue 10 years ago • 10 comments

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).

fdhex avatar Jul 19 '16 11:07 fdhex

This is something I noticed the other day, and should definitely be changed.

jbrooksuk avatar Jul 19 '16 11:07 jbrooksuk

Ping @joecohens.

jbrooksuk avatar Jul 19 '16 11:07 jbrooksuk

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.

fdhex avatar Jul 20 '16 11:07 fdhex

@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?

fdhex avatar Aug 15 '16 11:08 fdhex

Oops, it looks like it.

Would you mind making this change? :)

jbrooksuk avatar Aug 15 '16 11:08 jbrooksuk

I've fixed this now.

jbrooksuk avatar Aug 15 '16 17:08 jbrooksuk

Thanks! and sorry - had to focus on some other stuff afterwards.

fdhex avatar Aug 16 '16 07:08 fdhex

@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.

fdhex avatar Aug 16 '16 07:08 fdhex

New issue please ;)

jbrooksuk avatar Aug 16 '16 07:08 jbrooksuk

Sure, created #2061 ! :)

fdhex avatar Aug 16 '16 08:08 fdhex