Skip to content

Commit

Permalink
Fixed notification template (#6721)
Browse files Browse the repository at this point in the history
* Fixed notification template

* Made if-clause equal to append

Like Slack and email notification

* Add custom_body attribute to discord test

* Add missing attribute
  • Loading branch information
dvandonkelaar authored Jan 30, 2024
1 parent 97db492 commit d245ff7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions redash/destinations/discord.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def notify(self, alert, query, user, new_state, app, host, metadata, options):
"inline": True,
},
]
if alert.options.get("custom_body"):
fields.append({"name": "Description", "value": alert.options["custom_body"]})
if alert.custom_body:
fields.append({"name": "Description", "value": alert.custom_body})
if new_state == Alert.TRIGGERED_STATE:
if alert.options.get("custom_subject"):
text = alert.options["custom_subject"]
Expand Down
3 changes: 2 additions & 1 deletion tests/handlers/test_destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ def test_post(self):


def test_discord_notify_calls_requests_post():
alert = mock.Mock(spec_set=["id", "name", "options", "render_template"])
alert = mock.Mock(spec_set=["id", "name", "options", "custom_body", "render_template"])
alert.id = 1
alert.name = "Test Alert"
alert.options = {
"custom_subject": "Test custom subject",
"custom_body": "Test custom body",
}
alert.custom_body = alert.options["custom_body"]
alert.render_template = mock.Mock(return_value={"Rendered": "template"})
query = mock.Mock()
query.id = 1
Expand Down

0 comments on commit d245ff7

Please sign in to comment.