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.
This commit is contained in:
Lauryn Menard 2024-04-16 14:55:50 +02:00 committed by Tim Abbott
parent d0a62020ff
commit 20f4022391
4 changed files with 15 additions and 17 deletions

View File

@ -23,10 +23,10 @@
{% endfor %}
{% endif %}
{% if new_streams.html %}
<p class="digest_paragraph"><b>{% trans %}New streams{% endtrans %}</b></p>
{% if new_channels.html %}
<p class="digest_paragraph"><b>{% trans %}New channels{% endtrans %}</b></p>
<p class="digest_paragraph">{{ new_streams.html|display_list(1000)|safe }}.</p>
<p class="digest_paragraph">{{ new_channels.html|display_list(1000)|safe }}.</p>
{% endif %}
<br />

View File

@ -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 %}

View File

@ -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"<a href='{narrow_url}'>{stream.name}</a>"
streams_html.append(stream_link)
streams_plain.append(stream.name)
narrow_url = stream_narrow_url(realm, stream)
channel_link = f"<a href='{narrow_url}'>{stream.name}</a>"
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

View File

@ -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: