mirror of
https://github.com/zulip/zulip.git
synced 2025-11-22 07:21:23 +00:00
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:
committed by
Tim Abbott
parent
0f7341dd48
commit
243216cb60
@@ -21,7 +21,7 @@ def encode_stream(stream_id: int, stream_name: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def personal_narrow_url(realm: Realm, sender: UserProfile) -> 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)
|
encoded_user_name = re2.sub(r'[ "%\/<>`\p{C}]+', "-", sender.full_name)
|
||||||
pm_slug = str(sender.id) + "-" + encoded_user_name
|
pm_slug = str(sender.id) + "-" + encoded_user_name
|
||||||
return base_url + pm_slug
|
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:
|
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"
|
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
|
return base_url + pm_slug
|
||||||
|
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ def near_pm_message_url(realm: Realm, message: Dict[str, Any]) -> str:
|
|||||||
parts = [
|
parts = [
|
||||||
realm.uri,
|
realm.uri,
|
||||||
"#narrow",
|
"#narrow",
|
||||||
"pm-with",
|
"dm",
|
||||||
pm_str,
|
pm_str,
|
||||||
"near",
|
"near",
|
||||||
message_id,
|
message_id,
|
||||||
|
|||||||
@@ -1449,7 +1449,7 @@ class TestMissedMessages(ZulipTestCase):
|
|||||||
|
|
||||||
encoded_name = "Cordelia,-Lear's-daughter"
|
encoded_name = "Cordelia,-Lear's-daughter"
|
||||||
verify_body_include = [
|
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"
|
email_subject = "DMs with Cordelia, Lear's daughter"
|
||||||
self._test_cases(msg_id, verify_body_include, email_subject, send_as_user=False)
|
self._test_cases(msg_id, verify_body_include, email_subject, send_as_user=False)
|
||||||
|
|||||||
@@ -4270,4 +4270,4 @@ class PersonalMessagesNearTest(ZulipTestCase):
|
|||||||
realm=realm,
|
realm=realm,
|
||||||
message=message,
|
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")
|
||||||
|
|||||||
Reference in New Issue
Block a user