url-encoding: Update URLs for direct messages.

In a previous commit, the frontend of the web app was updated for
URLs with `#narrow/dm/...` for direct messages (group and 1-on-1).

Updates the URLs generated for email notifications and outgoing
webhook notification messages to use the new `/dm/...` format.
This commit is contained in:
Lauryn Menard
2023-04-14 17:04:06 +02:00
committed by Tim Abbott
parent 0f7341dd48
commit 243216cb60
3 changed files with 5 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ def encode_stream(stream_id: int, stream_name: str) -> str:
def personal_narrow_url(realm: Realm, sender: UserProfile) -> str:
base_url = f"{realm.uri}/#narrow/pm-with/"
base_url = f"{realm.uri}/#narrow/dm/"
encoded_user_name = re2.sub(r'[ "%\/<>`\p{C}]+', "-", sender.full_name)
pm_slug = str(sender.id) + "-" + encoded_user_name
return base_url + pm_slug
@@ -29,7 +29,7 @@ def personal_narrow_url(realm: Realm, sender: UserProfile) -> str:
def huddle_narrow_url(realm: Realm, other_user_ids: List[int]) -> str:
pm_slug = ",".join(str(user_id) for user_id in sorted(other_user_ids)) + "-group"
base_url = f"{realm.uri}/#narrow/pm-with/"
base_url = f"{realm.uri}/#narrow/dm/"
return base_url + pm_slug
@@ -91,7 +91,7 @@ def near_pm_message_url(realm: Realm, message: Dict[str, Any]) -> str:
parts = [
realm.uri,
"#narrow",
"pm-with",
"dm",
pm_str,
"near",
message_id,

View File

@@ -1449,7 +1449,7 @@ class TestMissedMessages(ZulipTestCase):
encoded_name = "Cordelia,-Lear's-daughter"
verify_body_include = [
f"view it in Zulip Dev Zulip: http://zulip.testserver/#narrow/pm-with/{cordelia.id}-{encoded_name}"
f"view it in Zulip Dev Zulip: http://zulip.testserver/#narrow/dm/{cordelia.id}-{encoded_name}"
]
email_subject = "DMs with Cordelia, Lear's daughter"
self._test_cases(msg_id, verify_body_include, email_subject, send_as_user=False)

View File

@@ -4270,4 +4270,4 @@ class PersonalMessagesNearTest(ZulipTestCase):
realm=realm,
message=message,
)
self.assertEqual(url, "http://zulip.testserver/#narrow/pm-with/77,80-pm/near/555")
self.assertEqual(url, "http://zulip.testserver/#narrow/dm/77,80-pm/near/555")