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.

topic_link_util: Use module to generate correct links.

Kislay Verma316d1cf285e5
diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.py
index b1d5bde2a80..2743a9e3952 100644
--- a/zerver/actions/message_edit.py
+++ b/zerver/actions/message_edit.py
@@ -72,6 +72,7 @@ from zerver.lib.topic import (
update_edit_history,
update_messages_for_topic_edit,
)
+from zerver.lib.topic_link_util import get_stream_topic_link_syntax
from zerver.lib.types import DirectMessageEditRequest, EditHistoryEvent, StreamMessageEditRequest
from zerver.lib.url_encoding import near_stream_message_url
from zerver.lib.user_message import bulk_insert_all_ums
@@ -286,8 +287,8 @@ def send_message_moved_breadcrumbs(
old_topic_name = message_edit_request.orig_topic_name
new_stream = message_edit_request.target_stream
new_topic_name = message_edit_request.target_topic_name
- old_topic_link = f"#**{old_stream.name}>{old_topic_name}**"
- new_topic_link = f"#**{new_stream.name}>{new_topic_name}**"
+ old_topic_link = get_stream_topic_link_syntax(old_stream.id, old_stream.name, old_topic_name)
+ new_topic_link = get_stream_topic_link_syntax(new_stream.id, new_stream.name, new_topic_name)
message = {
"id": target_message.id,
"stream_id": new_stream.id,
diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.py
index acd8347dbc6..a1b32358b5f 100644
--- a/zerver/actions/message_send.py
+++ b/zerver/actions/message_send.py
@@ -75,6 +75,7 @@ from zerver.lib.string_validation import check_stream_name
from zerver.lib.thumbnail import get_user_upload_previews, rewrite_thumbnailed_images
from zerver.lib.timestamp import timestamp_to_datetime
from zerver.lib.topic import participants_for_topic
+from zerver.lib.topic_link_util import get_stream_link_syntax
from zerver.lib.url_preview.types import UrlEmbedData
from zerver.lib.user_groups import (
check_any_user_has_permission_by_role,
@@ -1536,7 +1537,7 @@ def send_pm_if_empty_stream(
return
arg_dict = {
**arg_dict,
- "channel_name": f"#**{stream.name}**",
+ "channel_name": f"{get_stream_link_syntax(stream.id, stream.name)}",
}
content = _(
"Your bot {bot_identity} tried to send a message to "
diff --git a/zerver/views/streams.py b/zerver/views/streams.py
index 8b6e81d065e..dc6445beb9a 100644
--- a/zerver/views/streams.py
+++ b/zerver/views/streams.py
@@ -84,6 +84,7 @@ from zerver.lib.topic import (
maybe_rename_general_chat_to_empty_topic,
messages_for_topic,
)
+from zerver.lib.topic_link_util import get_stream_link_syntax
from zerver.lib.typed_endpoint import ApiParamConfig, PathOnly, typed_endpoint
from zerver.lib.typed_endpoint_validators import check_color
from zerver.lib.types import UserGroupMembersData
@@ -855,7 +856,9 @@ def send_messages_for_new_subscribers(
content = content.format(
user_name=silent_mention_syntax_for_user(user_profile),
- new_channels=", ".join(f"#**{s.name}**" for s in created_streams),
+ new_channels=", ".join(
+ f"{get_stream_link_syntax(s.id, s.name)}" for s in created_streams
+ ),
)
sender = get_system_bot(