slack_incoming: Handle explicit None text payload in webhook.

This commit is contained in:
Alex Vandiver 2021-07-12 16:26:09 -07:00 committed by Tim Abbott
parent 84e8d9ce98
commit 43f3f9221d
3 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,3 @@
{
"text": null
}

View File

@ -18,6 +18,12 @@ Hello, world.
expected_message, expected_message,
) )
def test_null_message(self) -> None:
self.check_webhook(
"null_text",
expect_noop=True,
)
def test_message_as_www_urlencoded(self) -> None: def test_message_as_www_urlencoded(self) -> None:
expected_topic = "devops" expected_topic = "devops"
expected_message = """ expected_message = """

View File

@ -50,7 +50,7 @@ def api_slack_incoming_webhook(
for attachment in payload["attachments"]: for attachment in payload["attachments"]:
body = add_attachment(attachment, body) 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"] body += payload["text"]
if "icon_emoji" in payload and payload["icon_emoji"] is not None: if "icon_emoji" in payload and payload["icon_emoji"] is not None:
body = "{} {}".format(payload["icon_emoji"], body) body = "{} {}".format(payload["icon_emoji"], body)