Skip to content

Commit c6fd0ba

Browse files
PieterCKtimabbott
authored andcommitted
integrations: Clean up duplicate functions.
This commit makes the Slack incoming webhook use the original `convert_slack_formatting` and `convert_slack_workspace_mentions` from `slack_message_conversion.py`. Previously those were not refactored out into two smaller functions yet. Fixes part of zulip#30827.
1 parent a194d62 commit c6fd0ba

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

zerver/webhooks/slack/view.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
from zerver.actions.message_send import send_rate_limited_pm_notification_to_bot_owner
99
from zerver.data_import.slack import check_token_access, get_slack_api_data
1010
from zerver.data_import.slack_message_conversion import (
11-
SLACK_BOLD_REGEX,
12-
SLACK_ITALIC_REGEX,
13-
SLACK_STRIKETHROUGH_REGEX,
1411
SLACK_USERMENTION_REGEX,
1512
convert_link_format,
1613
convert_mailto_format,
17-
convert_markdown_syntax,
14+
convert_slack_formatting,
15+
convert_slack_workspace_mentions,
1816
)
1917
from zerver.decorator import webhook_view
2018
from zerver.lib.exceptions import JsonableError, UnsupportedWebhookEventTypeError
@@ -97,22 +95,6 @@ def convert_to_zulip_markdown(text: str, slack_app_token: str) -> str:
9795
return text
9896

9997

100-
def convert_slack_formatting(text: str) -> str:
101-
text = convert_markdown_syntax(text, SLACK_BOLD_REGEX, "**")
102-
text = convert_markdown_syntax(text, SLACK_STRIKETHROUGH_REGEX, "~~")
103-
text = convert_markdown_syntax(text, SLACK_ITALIC_REGEX, "*")
104-
return text
105-
106-
107-
def convert_slack_workspace_mentions(text: str) -> str:
108-
# Map Slack's <!everyone>, <!channel> and <!here> mentions to @**all**.
109-
# No regex for this as it can be present anywhere in the sentence.
110-
text = text.replace("<!everyone>", "@**all**")
111-
text = text.replace("<!channel>", "@**all**")
112-
text = text.replace("<!here>", "@**all**")
113-
return text
114-
115-
11698
def replace_links(text: str) -> str:
11799
text, _ = convert_link_format(text)
118100
text, _ = convert_mailto_format(text)

0 commit comments

Comments
 (0)