Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

integrations: Clean up duplicate functions.

PieterCKc6fd0ba4247c
diff --git a/zerver/webhooks/slack/view.py b/zerver/webhooks/slack/view.py
index 53348574716..81a1245d8e5 100644
--- a/zerver/webhooks/slack/view.py
+++ b/zerver/webhooks/slack/view.py
@@ -8,13 +8,11 @@ from django.utils.translation import gettext as _
from zerver.actions.message_send import send_rate_limited_pm_notification_to_bot_owner
from zerver.data_import.slack import check_token_access, get_slack_api_data
from zerver.data_import.slack_message_conversion import (
- SLACK_BOLD_REGEX,
- SLACK_ITALIC_REGEX,
- SLACK_STRIKETHROUGH_REGEX,
SLACK_USERMENTION_REGEX,
convert_link_format,
convert_mailto_format,
- convert_markdown_syntax,
+ convert_slack_formatting,
+ convert_slack_workspace_mentions,
)
from zerver.decorator import webhook_view
from zerver.lib.exceptions import JsonableError, UnsupportedWebhookEventTypeError
@@ -97,22 +95,6 @@ def convert_to_zulip_markdown(text: str, slack_app_token: str) -> str:
return text
-def convert_slack_formatting(text: str) -> str:
- text = convert_markdown_syntax(text, SLACK_BOLD_REGEX, "**")
- text = convert_markdown_syntax(text, SLACK_STRIKETHROUGH_REGEX, "~~")
- text = convert_markdown_syntax(text, SLACK_ITALIC_REGEX, "*")
- return text
-
-
-def convert_slack_workspace_mentions(text: str) -> str:
- # Map Slack's <!everyone>, <!channel> and <!here> mentions to @**all**.
- # No regex for this as it can be present anywhere in the sentence.
- text = text.replace("<!everyone>", "@**all**")
- text = text.replace("<!channel>", "@**all**")
- text = text.replace("<!here>", "@**all**")
- return text
-
-
def replace_links(text: str) -> str:
text, _ = convert_link_format(text)
text, _ = convert_mailto_format(text)