alerta / alerta-contrib

Contributed integrations, plugins and custom webhooks
http://alerta.io
MIT License
119 stars 170 forks source link

webhooks action 'close' and status closed #332

Closed jjh74 closed 3 years ago

jjh74 commented 3 years ago

Issue Summary MSTeams, telegram (and probably Slack) webhook sets alert.set_status from action:

When action is 'close' status is also set to 'close'. I think with action 'close' the status should be set to 'closed' (not 'close') (https://docs.alerta.io/en/latest/api/alert.html#alert-status). AFAIK webui doesn't show status='close' if you filter for 'Closed' alerts (webui shows 'close' alerts if you remove all filters).

So I think the webhooks should do something like this:

newstatus = 'closed' if action == 'close' else action
alert.set_status(status=newstatus, text= ...)

If this seems reasonable I can create a patch for this.

satterly commented 3 years ago

You're right this is a bug. The fix is to use the Alert.from_action()` method like so ...

                alert.from_action(action, text='status changed via MS Teams webhook')

If you can submit a PR for this that would be great. I've already fixed Telegram and Slack.