mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
Use modern PM URLs in digest emails.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import urllib
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from zerver.models import Realm, Stream
|
||||
from zerver.models import Realm, Stream, UserProfile
|
||||
|
||||
def hash_util_encode(string: str) -> str:
|
||||
# Do the same encoding operation as hash_util.encodeHashComponent on the
|
||||
@@ -15,6 +15,12 @@ def encode_stream(stream_id: int, stream_name: str) -> str:
|
||||
stream_name = stream_name.replace(' ', '-')
|
||||
return str(stream_id) + '-' + hash_util_encode(stream_name)
|
||||
|
||||
def personal_narrow_url(realm: Realm, sender: UserProfile) -> str:
|
||||
base_url = "%s/#narrow/pm-with/" % (realm.uri,)
|
||||
email_user = sender.email.split('@')[0].lower()
|
||||
pm_slug = str(sender.id) + '-' + hash_util_encode(email_user)
|
||||
return base_url + pm_slug
|
||||
|
||||
def pm_narrow_url(realm: Realm, participants: List[str]) -> str:
|
||||
participants.sort()
|
||||
base_url = "%s/#narrow/pm-with/" % (realm.uri,)
|
||||
|
||||
Reference in New Issue
Block a user