From 69c042bff60ac5b794b0b9f57371b23ebc49659e Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Thu, 27 Oct 2022 19:19:22 -0700 Subject: [PATCH] email-notifs: Concatenate topic subject lines only in Jinja. Previously, stream names and topics (without consideration for their resolution status) were concatenated in Python-land and passed through to the template. To more cleanly separate concerns, and to prepare for accounting for topic resolution status being a third, independent, component of a subject line, instead pass stream and topic strings independently to the Jinja template, which can format them as it sees fit. --- templates/zerver/emails/missed_message.subject.txt | 2 +- zerver/lib/email_notifications.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/zerver/emails/missed_message.subject.txt b/templates/zerver/emails/missed_message.subject.txt index 7986af94b0..2ee788166e 100644 --- a/templates/zerver/emails/missed_message.subject.txt +++ b/templates/zerver/emails/missed_message.subject.txt @@ -1,7 +1,7 @@ {% if show_message_content %} {% if group_pm %} {% trans %}Group PMs with {{ huddle_display_name }}{% endtrans %} {% elif private_message %} {% trans %}PMs with {{ sender_str }}{% endtrans %} - {% elif stream_email_notify or mention %} #{{ stream_header }} + {% elif stream_email_notify or mention %} #{{ stream_name }} > {{ topic_name }} {% endif %} {% else %} {% trans %}New messages{% endtrans %} diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.py index ab994e042f..d2ca64b2ba 100644 --- a/zerver/lib/email_notifications.py +++ b/zerver/lib/email_notifications.py @@ -481,10 +481,10 @@ def do_send_missedmessage_events_reply_in_zulip( ) message = missed_messages[0]["message"] stream = Stream.objects.only("id", "name").get(id=message.recipient.type_id) - stream_header = f"{stream.name} > {message.topic_name()}" + topic_name = message.topic_name() context.update( stream_name=stream.name, - stream_header=stream_header, + topic_name=topic_name, ) else: raise AssertionError("Invalid messages!")