mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
Fixed notification template (#6721)
* Fixed notification template * Made if-clause equal to append Like Slack and email notification * Add custom_body attribute to discord test * Add missing attribute
This commit is contained in:
committed by
GitHub
parent
97db492531
commit
d245ff7bb1
@@ -42,8 +42,8 @@ class Discord(BaseDestination):
|
|||||||
"inline": True,
|
"inline": True,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
if alert.options.get("custom_body"):
|
if alert.custom_body:
|
||||||
fields.append({"name": "Description", "value": alert.options["custom_body"]})
|
fields.append({"name": "Description", "value": alert.custom_body})
|
||||||
if new_state == Alert.TRIGGERED_STATE:
|
if new_state == Alert.TRIGGERED_STATE:
|
||||||
if alert.options.get("custom_subject"):
|
if alert.options.get("custom_subject"):
|
||||||
text = alert.options["custom_subject"]
|
text = alert.options["custom_subject"]
|
||||||
|
|||||||
@@ -97,13 +97,14 @@ class TestDestinationResource(BaseTestCase):
|
|||||||
|
|
||||||
|
|
||||||
def test_discord_notify_calls_requests_post():
|
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.id = 1
|
||||||
alert.name = "Test Alert"
|
alert.name = "Test Alert"
|
||||||
alert.options = {
|
alert.options = {
|
||||||
"custom_subject": "Test custom subject",
|
"custom_subject": "Test custom subject",
|
||||||
"custom_body": "Test custom body",
|
"custom_body": "Test custom body",
|
||||||
}
|
}
|
||||||
|
alert.custom_body = alert.options["custom_body"]
|
||||||
alert.render_template = mock.Mock(return_value={"Rendered": "template"})
|
alert.render_template = mock.Mock(return_value={"Rendered": "template"})
|
||||||
query = mock.Mock()
|
query = mock.Mock()
|
||||||
query.id = 1
|
query.id = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user