Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
slack_incoming: Handle null blocks and attachments.
Alex Vandiver0511400d7317
diff --git a/zerver/webhooks/slack_incoming/fixtures/attachment.json b/zerver/webhooks/slack_incoming/fixtures/attachment.jsonindex c291642e886..096a0ea13e9 100644--- a/zerver/webhooks/slack_incoming/fixtures/attachment.json+++ b/zerver/webhooks/slack_incoming/fixtures/attachment.json@@ -1,6 +1,7 @@{"channel": "#prometheus-alerts","username": "Alertmanager",+ "blocks": null,"attachments": [{"title": "[FIRING:2] InstanceDown for api-server (env=\"prod\", severity=\"critical\")",diff --git a/zerver/webhooks/slack_incoming/view.py b/zerver/webhooks/slack_incoming/view.pyindex dcc701ac2d1..bb0b2fd52c8 100644--- a/zerver/webhooks/slack_incoming/view.py+++ b/zerver/webhooks/slack_incoming/view.py@@ -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)