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",
|
"channel": "#prometheus-alerts",
|
||||||
"username": "Alertmanager",
|
"username": "Alertmanager",
|
||||||
|
"blocks": null,
|
||||||
"attachments": [
|
"attachments": [
|
||||||
{
|
{
|
||||||
"title": "[FIRING:2] InstanceDown for api-server (env=\"prod\", severity=\"critical\")",
|
"title": "[FIRING:2] InstanceDown for api-server (env=\"prod\", severity=\"critical\")",
|
||||||
|
|
|
@ -50,11 +50,11 @@ def api_slack_incoming_webhook(
|
||||||
|
|
||||||
body = ""
|
body = ""
|
||||||
|
|
||||||
if "blocks" in payload:
|
if "blocks" in payload and payload["blocks"]:
|
||||||
for block in payload["blocks"]:
|
for block in payload["blocks"]:
|
||||||
body = add_block(block, body)
|
body = add_block(block, body)
|
||||||
|
|
||||||
if "attachments" in payload:
|
if "attachments" in payload and payload["attachments"]:
|
||||||
for attachment in payload["attachments"]:
|
for attachment in payload["attachments"]:
|
||||||
body = add_attachment(attachment, body)
|
body = add_attachment(attachment, body)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue