mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
stream settings: Use the .show-sender version of email address.
As requested in #13134.
This commit is contained in:
committed by
Tim Abbott
parent
307d8d8758
commit
dfd6771237
@@ -2696,7 +2696,7 @@ def notify_subscriptions_added(user_profile: UserProfile,
|
|||||||
is_web_public=stream.is_web_public,
|
is_web_public=stream.is_web_public,
|
||||||
is_announcement_only=stream.is_announcement_only,
|
is_announcement_only=stream.is_announcement_only,
|
||||||
color=subscription.color,
|
color=subscription.color,
|
||||||
email_address=encode_email_address(stream),
|
email_address=encode_email_address(stream, show_sender=True),
|
||||||
desktop_notifications=subscription.desktop_notifications,
|
desktop_notifications=subscription.desktop_notifications,
|
||||||
audible_notifications=subscription.audible_notifications,
|
audible_notifications=subscription.audible_notifications,
|
||||||
push_notifications=subscription.push_notifications,
|
push_notifications=subscription.push_notifications,
|
||||||
@@ -3557,7 +3557,7 @@ def do_rename_stream(stream: Stream,
|
|||||||
# date field in all cases.
|
# date field in all cases.
|
||||||
cache_delete_many(
|
cache_delete_many(
|
||||||
to_dict_cache_key_id(message.id) for message in messages)
|
to_dict_cache_key_id(message.id) for message in messages)
|
||||||
new_email = encode_email_address(stream)
|
new_email = encode_email_address(stream, show_sender=True)
|
||||||
|
|
||||||
# We will tell our users to essentially
|
# We will tell our users to essentially
|
||||||
# update stream.name = new_name where name = old_name
|
# update stream.name = new_name where name = old_name
|
||||||
@@ -4679,6 +4679,8 @@ def gather_subscriptions_helper(user_profile: UserProfile,
|
|||||||
if not sub["active"] and user_profile.is_guest:
|
if not sub["active"] and user_profile.is_guest:
|
||||||
subscribers = None
|
subscribers = None
|
||||||
|
|
||||||
|
email_address = encode_email_address_helper(stream["name"], stream["email_token"],
|
||||||
|
show_sender=True)
|
||||||
stream_dict = {'name': stream["name"],
|
stream_dict = {'name': stream["name"],
|
||||||
'in_home_view': not sub["is_muted"],
|
'in_home_view': not sub["is_muted"],
|
||||||
'is_muted': sub["is_muted"],
|
'is_muted': sub["is_muted"],
|
||||||
@@ -4699,7 +4701,7 @@ def gather_subscriptions_helper(user_profile: UserProfile,
|
|||||||
'stream_weekly_traffic': get_average_weekly_stream_traffic(stream["id"],
|
'stream_weekly_traffic': get_average_weekly_stream_traffic(stream["id"],
|
||||||
stream["date_created"],
|
stream["date_created"],
|
||||||
recent_traffic),
|
recent_traffic),
|
||||||
'email_address': encode_email_address_helper(stream["name"], stream["email_token"]),
|
'email_address': email_address,
|
||||||
'history_public_to_subscribers': stream['history_public_to_subscribers']}
|
'history_public_to_subscribers': stream['history_public_to_subscribers']}
|
||||||
|
|
||||||
if subscribers is not None:
|
if subscribers is not None:
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ def get_email_gateway_message_string_from_address(address: str) -> str:
|
|||||||
|
|
||||||
return msg_string
|
return msg_string
|
||||||
|
|
||||||
def encode_email_address(stream: Stream) -> str:
|
def encode_email_address(stream: Stream, show_sender: bool=False) -> str:
|
||||||
return encode_email_address_helper(stream.name, stream.email_token)
|
return encode_email_address_helper(stream.name, stream.email_token, show_sender)
|
||||||
|
|
||||||
def encode_email_address_helper(name: str, email_token: str) -> str:
|
def encode_email_address_helper(name: str, email_token: str, show_sender: bool=False) -> str:
|
||||||
# Some deployments may not use the email gateway
|
# Some deployments may not use the email gateway
|
||||||
if settings.EMAIL_GATEWAY_PATTERN == '':
|
if settings.EMAIL_GATEWAY_PATTERN == '':
|
||||||
return ''
|
return ''
|
||||||
@@ -52,6 +52,9 @@ def encode_email_address_helper(name: str, email_token: str) -> str:
|
|||||||
else:
|
else:
|
||||||
encoded_token = email_token
|
encoded_token = email_token
|
||||||
|
|
||||||
|
if show_sender:
|
||||||
|
encoded_token += ".show-sender"
|
||||||
|
|
||||||
return settings.EMAIL_GATEWAY_PATTERN % (encoded_token,)
|
return settings.EMAIL_GATEWAY_PATTERN % (encoded_token,)
|
||||||
|
|
||||||
def decode_email_address(email: str) -> Tuple[str, Dict[str, bool]]:
|
def decode_email_address(email: str) -> Tuple[str, Dict[str, bool]]:
|
||||||
|
|||||||
@@ -150,6 +150,14 @@ class TestEncodeDecode(ZulipTestCase):
|
|||||||
token = decode_email_address(stream_to_address)[0]
|
token = decode_email_address(stream_to_address)[0]
|
||||||
self.assertEqual(token, stream.email_token)
|
self.assertEqual(token, stream.email_token)
|
||||||
|
|
||||||
|
def test_encode_with_show_sender(self) -> None:
|
||||||
|
stream = get_stream("Denmark", get_realm("zulip"))
|
||||||
|
stream_to_address = encode_email_address(stream, show_sender=True)
|
||||||
|
|
||||||
|
token, options = decode_email_address(stream_to_address)
|
||||||
|
self._assert_options(options, show_sender=True)
|
||||||
|
self.assertEqual(token, stream.email_token)
|
||||||
|
|
||||||
class TestGetMissedMessageToken(ZulipTestCase):
|
class TestGetMissedMessageToken(ZulipTestCase):
|
||||||
def test_get_missed_message_token(self) -> None:
|
def test_get_missed_message_token(self) -> None:
|
||||||
with self.settings(EMAIL_GATEWAY_PATTERN="%s@example.com"):
|
with self.settings(EMAIL_GATEWAY_PATTERN="%s@example.com"):
|
||||||
|
|||||||
Reference in New Issue
Block a user