From 20f4022391264e5428fbb3ef979d99d7b184962a Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Tue, 16 Apr 2024 14:55:50 +0200 Subject: [PATCH] email-digest: Update translated strings for stream to channel rename. Updates the translated "New streams" string in the email digest to instead by "New channels". Also, marks that for translation in the plain text version of the email. Updates the generated stream/channel url to use stream_narrow_url in preparation for updating stream narrow urls for the rename. Part of stream to channel rename project. --- templates/zerver/emails/digest.html | 6 +++--- templates/zerver/emails/digest.txt | 4 ++-- zerver/lib/digest.py | 20 +++++++++----------- zerver/tests/test_digest.py | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/templates/zerver/emails/digest.html b/templates/zerver/emails/digest.html index 774b4ef08c..ee2673a561 100644 --- a/templates/zerver/emails/digest.html +++ b/templates/zerver/emails/digest.html @@ -23,10 +23,10 @@ {% endfor %} {% endif %} - {% if new_streams.html %} -

{% trans %}New streams{% endtrans %}

+ {% if new_channels.html %} +

{% trans %}New channels{% endtrans %}

-

{{ new_streams.html|display_list(1000)|safe }}.

+

{{ new_channels.html|display_list(1000)|safe }}.

{% endif %}
diff --git a/templates/zerver/emails/digest.txt b/templates/zerver/emails/digest.txt index c0cf778c78..cb3715f520 100644 --- a/templates/zerver/emails/digest.txt +++ b/templates/zerver/emails/digest.txt @@ -5,8 +5,8 @@ {% endfor %}{% endfor %} {% if convo.count > 0 %}+ {{ convo.count }} more message{{ convo.count|pluralize }} by {{ convo.participants|display_list(4) }}.{% endif %}{% endfor %}{% endfor %}{% endif %} -{% if new_streams.plain %}** New streams ** - {{ new_streams.plain|display_list(1000) }}. +{% if new_channels.plain %}** {% trans %}New channels{% endtrans %} ** + {{ new_channels.plain|display_list(1000) }}. {% endif %} {% trans organization_url=realm_uri %}Click here to log in to Zulip and catch up: {{ organization_url }}.{% endtrans %} diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py index c3cb1e18e8..fd282965f1 100644 --- a/zerver/lib/digest.py +++ b/zerver/lib/digest.py @@ -19,7 +19,7 @@ from zerver.lib.logging_util import log_to_file from zerver.lib.message import get_last_message_id from zerver.lib.queue import queue_json_publish from zerver.lib.send_email import FromAddress, send_future_email -from zerver.lib.url_encoding import encode_stream +from zerver.lib.url_encoding import stream_narrow_url from zerver.models import ( Message, Realm, @@ -255,18 +255,16 @@ def gather_new_streams( else: new_streams = [stream for stream in recently_created_streams if stream.is_web_public] - base_url = f"{realm.uri}/#narrow/stream/" - - streams_html = [] - streams_plain = [] + channels_html = [] + channels_plain = [] for stream in new_streams: - narrow_url = base_url + encode_stream(stream.id, stream.name) - stream_link = f"{stream.name}" - streams_html.append(stream_link) - streams_plain.append(stream.name) + narrow_url = stream_narrow_url(realm, stream) + channel_link = f"{stream.name}" + channels_html.append(channel_link) + channels_plain.append(stream.name) - return len(new_streams), {"html": streams_html, "plain": streams_plain} + return len(new_streams), {"html": channels_html, "plain": channels_plain} def enough_traffic(hot_conversations: str, new_streams: int) -> bool: @@ -376,7 +374,7 @@ def bulk_get_digest_context( recently_created_streams=recently_created_streams, can_access_public=user.can_access_public_streams(), ) - context["new_streams"] = new_streams + context["new_channels"] = new_streams context["new_streams_count"] = new_streams_count yield user, context diff --git a/zerver/tests/test_digest.py b/zerver/tests/test_digest.py index e5099b516e..d7e9857517 100644 --- a/zerver/tests/test_digest.py +++ b/zerver/tests/test_digest.py @@ -186,7 +186,7 @@ class TestDigestEmailMessages(ZulipTestCase): kwargs = mock_send_future_email.call_args[1] self.assertEqual(kwargs["to_user_ids"], [polonius.id]) - new_stream_names = kwargs["context"]["new_streams"]["plain"] + new_stream_names = kwargs["context"]["new_channels"]["plain"] self.assertTrue("web_public_stream" in new_stream_names) def test_no_logging(self) -> None: