From 6c41bd2c94c14df66e79c7b08d3ee55f107f574c Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:10:24 +0300 Subject: [PATCH 01/11] Update utils.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- notifications/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notifications/utils.py b/notifications/utils.py index 733a1cb..45bce8d 100644 --- a/notifications/utils.py +++ b/notifications/utils.py @@ -64,6 +64,8 @@ def __notify_blocks(event_name, block, queryset=None): targets = queryset.filter(service=Subscription.Service.SLACK) if targets: api_kwargs = event.slack_api_kwargs() + api_kwargs["unfurl_links"] = False + api_kwargs["unfurl_media"] = False message, extra_kwargs = block.render_slack() api_kwargs.update(extra_kwargs) for subscription in targets: From 03103cab1e739b5647053e81915be07a167c1e80 Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:18:29 +0300 Subject: [PATCH 02/11] Update test_blocks.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- testapp/tests/test_blocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testapp/tests/test_blocks.py b/testapp/tests/test_blocks.py index 7774bb2..40734b1 100644 --- a/testapp/tests/test_blocks.py +++ b/testapp/tests/test_blocks.py @@ -128,7 +128,7 @@ def test_message_blocks(self): self.sc_mock.return_value.chat_postMessage.assert_called_once_with( text='*Fruits in bag:* 1\napple\n*Cars in garage:* 2\nfiat\ntesla', channel='@someone', - unfurl_links=0, + unfurl_links=False, username='NotTestBot', as_user=0, icon_emoji=':something:', From 58e30db391957af4a965e001b3dc6599883916e0 Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:20:56 +0300 Subject: [PATCH 03/11] Update test_blocks.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- testapp/tests/test_blocks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/testapp/tests/test_blocks.py b/testapp/tests/test_blocks.py index 40734b1..70037fd 100644 --- a/testapp/tests/test_blocks.py +++ b/testapp/tests/test_blocks.py @@ -129,6 +129,7 @@ def test_message_blocks(self): text='*Fruits in bag:* 1\napple\n*Cars in garage:* 2\nfiat\ntesla', channel='@someone', unfurl_links=False, + unfurl_media=False, username='NotTestBot', as_user=0, icon_emoji=':something:', From 10652388be8944347eef55c5d60de2e5b99b599d Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:24:49 +0300 Subject: [PATCH 04/11] Update test_blocks.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- testapp/tests/test_blocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testapp/tests/test_blocks.py b/testapp/tests/test_blocks.py index 70037fd..809a5fa 100644 --- a/testapp/tests/test_blocks.py +++ b/testapp/tests/test_blocks.py @@ -83,7 +83,7 @@ def test_templated(self): channel='@someone', icon_emoji=':something:', text='dull version', - unfurl_links=0, + unfurl_links=False, username='NotTestBot', ), ) From 3e8b802a88c53578fb8e829dff6a0de7eecb3b88 Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:32:04 +0300 Subject: [PATCH 05/11] Update utils.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- notifications/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/notifications/utils.py b/notifications/utils.py index 45bce8d..37b3b3a 100644 --- a/notifications/utils.py +++ b/notifications/utils.py @@ -64,8 +64,6 @@ def __notify_blocks(event_name, block, queryset=None): targets = queryset.filter(service=Subscription.Service.SLACK) if targets: api_kwargs = event.slack_api_kwargs() - api_kwargs["unfurl_links"] = False - api_kwargs["unfurl_media"] = False message, extra_kwargs = block.render_slack() api_kwargs.update(extra_kwargs) for subscription in targets: @@ -115,6 +113,7 @@ def notify( template=None, context=None, create_link=False, + unfurl_links=False, additional_email_targets=None, attachments: Optional[list[Attachment]] = None, slack_attachments=None, @@ -139,6 +138,8 @@ def notify( slack_text = f'{subject}: {message}' if subject else message api_kwargs = event.slack_api_kwargs() + if unfurl_links: + api_kwargs["unfurl_links"] = False if slack_attachments: # TODO: can this be taken from a more "generic" arg and also use it in email? api_kwargs['attachments'] = slack_attachments From c2717e319534a56fd439774a12ee55783a122229 Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:33:39 +0300 Subject: [PATCH 06/11] Update test_blocks.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- testapp/tests/test_blocks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/testapp/tests/test_blocks.py b/testapp/tests/test_blocks.py index 809a5fa..35cc77e 100644 --- a/testapp/tests/test_blocks.py +++ b/testapp/tests/test_blocks.py @@ -129,7 +129,6 @@ def test_message_blocks(self): text='*Fruits in bag:* 1\napple\n*Cars in garage:* 2\nfiat\ntesla', channel='@someone', unfurl_links=False, - unfurl_media=False, username='NotTestBot', as_user=0, icon_emoji=':something:', From 368e9ef8b2c47db34f23a328068bbe962e2b7c5c Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:41:08 +0300 Subject: [PATCH 07/11] Update utils.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- notifications/utils.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/notifications/utils.py b/notifications/utils.py index 37b3b3a..41c115c 100644 --- a/notifications/utils.py +++ b/notifications/utils.py @@ -138,8 +138,6 @@ def notify( slack_text = f'{subject}: {message}' if subject else message api_kwargs = event.slack_api_kwargs() - if unfurl_links: - api_kwargs["unfurl_links"] = False if slack_attachments: # TODO: can this be taken from a more "generic" arg and also use it in email? api_kwargs['attachments'] = slack_attachments From 72e665d98f8ae353af5c863ebe105a04585a939b Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:46:13 +0300 Subject: [PATCH 08/11] Update utils.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- notifications/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/notifications/utils.py b/notifications/utils.py index 41c115c..67e349d 100644 --- a/notifications/utils.py +++ b/notifications/utils.py @@ -173,6 +173,7 @@ def notify( template=template, event=event, create_link=create_link, + unfurl_urls=unfurl_urls, recipient_list=recipient_list, context=context, mail_options=mail_options, @@ -190,6 +191,7 @@ def prepare_and_store_notifications( template: str, event: Event, create_link: bool, + unfurl_urls: bool, recipient_list: list, context: str, mail_options: dict, @@ -202,6 +204,7 @@ def prepare_and_store_notifications( context=context, from_email=event.mail_from or settings.NOTIFICATIONS_MAIL_FROM, create_link=create_link, + unfurl_urls=unfurl_urls, to=recipient_list, ) mail_options["subject"] = template_message.subject From 1588482973daa5b21fd44bdc7f1e7a2f49dda2f4 Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:49:05 +0300 Subject: [PATCH 09/11] Update utils.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- notifications/utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/notifications/utils.py b/notifications/utils.py index 67e349d..19a2c5e 100644 --- a/notifications/utils.py +++ b/notifications/utils.py @@ -138,6 +138,7 @@ def notify( slack_text = f'{subject}: {message}' if subject else message api_kwargs = event.slack_api_kwargs() + api_kwargs["unfurl_links"] = False if slack_attachments: # TODO: can this be taken from a more "generic" arg and also use it in email? api_kwargs['attachments'] = slack_attachments @@ -173,7 +174,6 @@ def notify( template=template, event=event, create_link=create_link, - unfurl_urls=unfurl_urls, recipient_list=recipient_list, context=context, mail_options=mail_options, @@ -191,7 +191,6 @@ def prepare_and_store_notifications( template: str, event: Event, create_link: bool, - unfurl_urls: bool, recipient_list: list, context: str, mail_options: dict, @@ -204,7 +203,6 @@ def prepare_and_store_notifications( context=context, from_email=event.mail_from or settings.NOTIFICATIONS_MAIL_FROM, create_link=create_link, - unfurl_urls=unfurl_urls, to=recipient_list, ) mail_options["subject"] = template_message.subject From b680b36595ed70a60467e5aa3dba49fae860a274 Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 14:51:38 +0300 Subject: [PATCH 10/11] Update __init__.py Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- notifications/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifications/__init__.py b/notifications/__init__.py index 3dc1f76..485f44a 100644 --- a/notifications/__init__.py +++ b/notifications/__init__.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "0.1.1" From bb4e3c5b6c765ae75c1a2520e0e0ea551e204588 Mon Sep 17 00:00:00 2001 From: pacuraro <122358966+pacuraro@users.noreply.github.com> Date: Tue, 7 Oct 2025 15:27:02 +0300 Subject: [PATCH 11/11] Apply suggestions from code review Co-authored-by: peterbppb <91122533+peterbppb@users.noreply.github.com> Signed-off-by: pacuraro <122358966+pacuraro@users.noreply.github.com> --- notifications/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifications/utils.py b/notifications/utils.py index 19a2c5e..efadfd1 100644 --- a/notifications/utils.py +++ b/notifications/utils.py @@ -138,7 +138,7 @@ def notify( slack_text = f'{subject}: {message}' if subject else message api_kwargs = event.slack_api_kwargs() - api_kwargs["unfurl_links"] = False + api_kwargs["unfurl_links"] = unfurl_links if slack_attachments: # TODO: can this be taken from a more "generic" arg and also use it in email? api_kwargs['attachments'] = slack_attachments