From 0226726dd5e639000cc61e7b12d11beb8a4bd704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=A1=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Tue, 6 Sep 2022 15:39:41 +0300 Subject: [PATCH 01/10] add CP channel prefix --- plugins/modules/notification/slack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py index d9854129327..e9703572008 100644 --- a/plugins/modules/notification/slack.py +++ b/plugins/modules/notification/slack.py @@ -294,7 +294,7 @@ def build_payload_for_slack(text, channel, thread_id, username, icon_url, icon_e # With a custom color we have to set the message as attachment, and explicitly turn markdown parsing on for it. payload = dict(attachments=[dict(text=escape_quotes(text), color=color, mrkdwn_in=["text"])]) if channel is not None: - if channel.startswith(('#', '@', 'C0', 'GF', 'G0')): + if channel.startswith(('#', '@', 'C0', 'GF', 'G0', 'CP')): payload['channel'] = channel else: payload['channel'] = '#' + channel From 90ca8be37ce819902da0b7f8e50320fd57c468be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=A1=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Wed, 7 Sep 2022 06:49:31 +0300 Subject: [PATCH 02/10] changelog added --- changelogs/fragments/5249-add-new-channel-prefix.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/5249-add-new-channel-prefix.yml diff --git a/changelogs/fragments/5249-add-new-channel-prefix.yml b/changelogs/fragments/5249-add-new-channel-prefix.yml new file mode 100644 index 00000000000..7cc6c20d9c8 --- /dev/null +++ b/changelogs/fragments/5249-add-new-channel-prefix.yml @@ -0,0 +1,2 @@ +bugfixes: + - slack - fix message update for channels which starts with ``CP``. When ``message-id`` was passed it failed for channels wich starts with ``CP`` because of ``#`` simbol was added befor the ``channel_id``.(https://github.com/ansible-collections/community.general/pull/5249#issuecomment-1238520553). From fa75fd7bc2fd5328f6f458ef43c91a25a81cbc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=A1=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Wed, 7 Sep 2022 07:11:03 +0300 Subject: [PATCH 03/10] altered docs --- plugins/modules/notification/slack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py index e9703572008..8b32b4e1374 100644 --- a/plugins/modules/notification/slack.py +++ b/plugins/modules/notification/slack.py @@ -68,7 +68,7 @@ type: str message_id: description: - - Optional. Message ID to edit, instead of posting a new message. + - Optional. Message ID to edit, instead of posting a new message. If supplyed `channel_id` must be in form of `C0xxxxxxx`. use `{{ slack_response.channel_id }}` to get `channel_id` from previous task run. Corresponds to C(ts) in the Slack API (U(https://api.slack.com/messaging/modifying)). type: str version_added: 1.2.0 @@ -234,7 +234,7 @@ - name: Edit message community.general.slack: token: thetoken/generatedby/slack - channel: "{{ slack_response.channel }}" + channel: "{{ slack_response.channel }}" #doesn't accept channel name. Must be `channel_id` stored in `slack_response` from the previous task. msg: Deployment complete! message_id: "{{ slack_response.ts }}" """ From e232487bb0d8398ad0ed5054976fb349d1a7c305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=A1=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Wed, 7 Sep 2022 07:14:03 +0300 Subject: [PATCH 04/10] added description for docs change --- changelogs/fragments/5249-add-new-channel-prefix.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/changelogs/fragments/5249-add-new-channel-prefix.yml b/changelogs/fragments/5249-add-new-channel-prefix.yml index 7cc6c20d9c8..9b83aa9f16f 100644 --- a/changelogs/fragments/5249-add-new-channel-prefix.yml +++ b/changelogs/fragments/5249-add-new-channel-prefix.yml @@ -1,2 +1,3 @@ bugfixes: - slack - fix message update for channels which starts with ``CP``. When ``message-id`` was passed it failed for channels wich starts with ``CP`` because of ``#`` simbol was added befor the ``channel_id``.(https://github.com/ansible-collections/community.general/pull/5249#issuecomment-1238520553). + - slack - docs improved. It wasn't clear that when `message_id` is supplied `channel_id` couldn't be a channel name. It has to be literal Channel ID returned in payload from API in previous task. From ae7f95d48bad666985b409cf05e3a7ef3838bb0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=A1=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Wed, 7 Sep 2022 07:28:18 +0300 Subject: [PATCH 05/10] fix line length --- plugins/modules/notification/slack.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py index 8b32b4e1374..b63e24424a0 100644 --- a/plugins/modules/notification/slack.py +++ b/plugins/modules/notification/slack.py @@ -68,7 +68,8 @@ type: str message_id: description: - - Optional. Message ID to edit, instead of posting a new message. If supplyed `channel_id` must be in form of `C0xxxxxxx`. use `{{ slack_response.channel_id }}` to get `channel_id` from previous task run. + - Optional. Message ID to edit, instead of posting a new message. + If supplyed `channel_id` must be in form of `C0xxxxxxx`. use `{{ slack_response.channel_id }}` to get `channel_id` from previous task run. Corresponds to C(ts) in the Slack API (U(https://api.slack.com/messaging/modifying)). type: str version_added: 1.2.0 From eef848872763fa5e529799486b42d006ff4c7abb Mon Sep 17 00:00:00 2001 From: sprnza Date: Thu, 8 Sep 2022 10:28:21 +0300 Subject: [PATCH 06/10] Update plugins/modules/notification/slack.py Co-authored-by: Felix Fontein --- plugins/modules/notification/slack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py index b63e24424a0..be4fac5a117 100644 --- a/plugins/modules/notification/slack.py +++ b/plugins/modules/notification/slack.py @@ -69,7 +69,7 @@ message_id: description: - Optional. Message ID to edit, instead of posting a new message. - If supplyed `channel_id` must be in form of `C0xxxxxxx`. use `{{ slack_response.channel_id }}` to get `channel_id` from previous task run. + - If supplied I(channel_id) must be in form of C(C0xxxxxxx). use C({{ slack_response.channel_id }}) to get I(channel_id) from previous task run. Corresponds to C(ts) in the Slack API (U(https://api.slack.com/messaging/modifying)). type: str version_added: 1.2.0 From cb4daaba1911ae7c1f0628f1368bfab8ddbe7c98 Mon Sep 17 00:00:00 2001 From: sprnza Date: Thu, 8 Sep 2022 10:28:54 +0300 Subject: [PATCH 07/10] Update plugins/modules/notification/slack.py Co-authored-by: Felix Fontein --- plugins/modules/notification/slack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py index be4fac5a117..efd2f73a65b 100644 --- a/plugins/modules/notification/slack.py +++ b/plugins/modules/notification/slack.py @@ -70,7 +70,7 @@ description: - Optional. Message ID to edit, instead of posting a new message. - If supplied I(channel_id) must be in form of C(C0xxxxxxx). use C({{ slack_response.channel_id }}) to get I(channel_id) from previous task run. - Corresponds to C(ts) in the Slack API (U(https://api.slack.com/messaging/modifying)). + - Corresponds to C(ts) in the Slack API (U(https://api.slack.com/messaging/modifying)). type: str version_added: 1.2.0 username: From 38a9d235af72412aa3164bd70e2a773fa9272441 Mon Sep 17 00:00:00 2001 From: sprnza Date: Thu, 8 Sep 2022 10:29:07 +0300 Subject: [PATCH 08/10] Update plugins/modules/notification/slack.py Co-authored-by: Felix Fontein --- plugins/modules/notification/slack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py index efd2f73a65b..276e4428d9d 100644 --- a/plugins/modules/notification/slack.py +++ b/plugins/modules/notification/slack.py @@ -68,7 +68,7 @@ type: str message_id: description: - - Optional. Message ID to edit, instead of posting a new message. + - Optional. Message ID to edit, instead of posting a new message. - If supplied I(channel_id) must be in form of C(C0xxxxxxx). use C({{ slack_response.channel_id }}) to get I(channel_id) from previous task run. - Corresponds to C(ts) in the Slack API (U(https://api.slack.com/messaging/modifying)). type: str From 9671c85576653e35e388410bda268efa61997d62 Mon Sep 17 00:00:00 2001 From: sprnza Date: Thu, 8 Sep 2022 10:29:29 +0300 Subject: [PATCH 09/10] Update plugins/modules/notification/slack.py Co-authored-by: Felix Fontein --- plugins/modules/notification/slack.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py index 276e4428d9d..b6d9005fd73 100644 --- a/plugins/modules/notification/slack.py +++ b/plugins/modules/notification/slack.py @@ -235,7 +235,9 @@ - name: Edit message community.general.slack: token: thetoken/generatedby/slack - channel: "{{ slack_response.channel }}" #doesn't accept channel name. Must be `channel_id` stored in `slack_response` from the previous task. + # The 'channel' option does not accept the channel name. It must use the 'channel_id', + # which can be retrieved for example from 'slack_response' from the previous task. + channel: "{{ slack_response.channel }}" msg: Deployment complete! message_id: "{{ slack_response.ts }}" """ From 521e9efeb7c67770fa0d36eeb379ed979532bdff Mon Sep 17 00:00:00 2001 From: sprnza Date: Thu, 8 Sep 2022 10:29:40 +0300 Subject: [PATCH 10/10] Update changelogs/fragments/5249-add-new-channel-prefix.yml Co-authored-by: Felix Fontein --- changelogs/fragments/5249-add-new-channel-prefix.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/changelogs/fragments/5249-add-new-channel-prefix.yml b/changelogs/fragments/5249-add-new-channel-prefix.yml index 9b83aa9f16f..9740e3a1865 100644 --- a/changelogs/fragments/5249-add-new-channel-prefix.yml +++ b/changelogs/fragments/5249-add-new-channel-prefix.yml @@ -1,3 +1,2 @@ bugfixes: - - slack - fix message update for channels which starts with ``CP``. When ``message-id`` was passed it failed for channels wich starts with ``CP`` because of ``#`` simbol was added befor the ``channel_id``.(https://github.com/ansible-collections/community.general/pull/5249#issuecomment-1238520553). - - slack - docs improved. It wasn't clear that when `message_id` is supplied `channel_id` couldn't be a channel name. It has to be literal Channel ID returned in payload from API in previous task. + - slack - fix message update for channels which start with ``CP``. When ``message-id`` was passed it failed for channels which started with ``CP`` because the ``#`` symbol was added before the ``channel_id`` (https://github.com/ansible-collections/community.general/pull/5249).