From fa92f8efb052db5d54b4d7518c47383b03eaa356 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 3 Jan 2022 19:43:47 +0100 Subject: [PATCH] slack - use UTF-8 charset in content-type header (#3933) (#3970) * Use UTF-8 charset in content-type header * Add changelog fragment (cherry picked from commit a4ab85fd68d192e6c9900afa1dcfc7019af84793) Co-authored-by: bluikko <14869000+bluikko@users.noreply.github.com> --- changelogs/fragments/3933-slack-charset-header.yaml | 2 ++ plugins/modules/notification/slack.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/3933-slack-charset-header.yaml diff --git a/changelogs/fragments/3933-slack-charset-header.yaml b/changelogs/fragments/3933-slack-charset-header.yaml new file mode 100644 index 0000000000..581fd7a2e8 --- /dev/null +++ b/changelogs/fragments/3933-slack-charset-header.yaml @@ -0,0 +1,2 @@ +bugfixes: + - slack - add ``charset`` to HTTP headers to avoid Slack API warning (https://github.com/ansible-collections/community.general/issues/3932). diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py index 3023bd9d8a..bdc839f9a8 100644 --- a/plugins/modules/notification/slack.py +++ b/plugins/modules/notification/slack.py @@ -346,7 +346,7 @@ def build_payload_for_slack(text, channel, thread_id, username, icon_url, icon_e def get_slack_message(module, token, channel, ts): headers = { - 'Content-Type': 'application/json', + 'Content-Type': 'application/json; charset=UTF-8', 'Accept': 'application/json', 'Authorization': 'Bearer ' + token } @@ -383,7 +383,7 @@ def do_notify_slack(module, domain, token, payload): slack_uri = OLD_SLACK_INCOMING_WEBHOOK % (domain, token) headers = { - 'Content-Type': 'application/json', + 'Content-Type': 'application/json; charset=UTF-8', 'Accept': 'application/json', } if use_webapi: