Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
slack_incoming: Handle explicit None text payload in webhook.
Alex Vandiver43f3f9221d58
diff --git a/zerver/webhooks/slack_incoming/fixtures/null_text.json b/zerver/webhooks/slack_incoming/fixtures/null_text.jsonnew file mode 100644index 00000000000..0a3b940c39d--- /dev/null+++ b/zerver/webhooks/slack_incoming/fixtures/null_text.json@@ -0,0 +1,3 @@+{+ "text": null+}diff --git a/zerver/webhooks/slack_incoming/tests.py b/zerver/webhooks/slack_incoming/tests.pyindex 3b0a5de9c51..2acaa5e345b 100644--- a/zerver/webhooks/slack_incoming/tests.py+++ b/zerver/webhooks/slack_incoming/tests.py@@ -18,6 +18,12 @@ Hello, world.expected_message,)+ def test_null_message(self) -> None:+ self.check_webhook(+ "null_text",+ expect_noop=True,+ )+def test_message_as_www_urlencoded(self) -> None:expected_topic = "devops"expected_message = """diff --git a/zerver/webhooks/slack_incoming/view.py b/zerver/webhooks/slack_incoming/view.pyindex fcde7b03943..e9da1bff451 100644--- a/zerver/webhooks/slack_incoming/view.py+++ b/zerver/webhooks/slack_incoming/view.py@@ -50,7 +50,7 @@ def api_slack_incoming_webhook(for attachment in payload["attachments"]:body = add_attachment(attachment, body)- if body == "" and "text" in payload:+ if body == "" and "text" in payload and payload["text"] is not None:body += payload["text"]if "icon_emoji" in payload and payload["icon_emoji"] is not None:body = "{} {}".format(payload["icon_emoji"], body)