mirror of https://github.com/zulip/zulip.git
slack_incoming: Handle null blocks and attachments.
This is not accepted according to Slack's block-builder, but is attested in the wild.
This commit is contained in:
parent
74cf9a1e9f
commit
0511400d73
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"channel": "#prometheus-alerts",
|
||||
"username": "Alertmanager",
|
||||
"blocks": null,
|
||||
"attachments": [
|
||||
{
|
||||
"title": "[FIRING:2] InstanceDown for api-server (env=\"prod\", severity=\"critical\")",
|
||||
|
|
|
@ -50,11 +50,11 @@ def api_slack_incoming_webhook(
|
|||
|
||||
body = ""
|
||||
|
||||
if "blocks" in payload:
|
||||
if "blocks" in payload and payload["blocks"]:
|
||||
for block in payload["blocks"]:
|
||||
body = add_block(block, body)
|
||||
|
||||
if "attachments" in payload:
|
||||
if "attachments" in payload and payload["attachments"]:
|
||||
for attachment in payload["attachments"]:
|
||||
body = add_attachment(attachment, body)
|
||||
|
||||
|
|
Loading…
Reference in New Issue