From 69f159792e0a8332ab94157b59247c5e52d056a5 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sat, 10 Oct 2020 21:31:11 +0300 Subject: [PATCH] Only use summary for quote if text is empty For text messages, summary joins all lines into one, so multi-line quotes look bad in Thunderbird. --- python/tests/test_account.py | 4 ++-- src/message.rs | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index a2640fbb1..543317b1e 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -479,7 +479,7 @@ class TestOfflineChat: def test_quote(self, chat1): """Offline quoting test""" msg = Message.new_empty(chat1.account, "text") - msg.set_text("message") + msg.set_text("Multi\nline\nmessage") assert msg.quoted_text is None # Prepare message to assign it a Message-Id. @@ -489,7 +489,7 @@ class TestOfflineChat: reply_msg = Message.new_empty(chat1.account, "text") reply_msg.set_text("reply") reply_msg.quote = msg - assert reply_msg.quoted_text == "message" + assert reply_msg.quoted_text == "Multi\nline\nmessage" def test_group_chat_many_members_add_remove(self, ac1, lp): lp.sec("ac1: creating group chat with 10 other members") diff --git a/src/message.rs b/src/message.rs index 9dbc08206..967e8efdd 100644 --- a/src/message.rs +++ b/src/message.rs @@ -764,8 +764,16 @@ impl Message { self.param.set(Param::GuaranteeE2ee, "1"); } - self.param - .set(Param::Quote, quote.get_summarytext(context, 500).await); + let text = quote.get_text().unwrap_or_default(); + self.param.set( + Param::Quote, + if text.is_empty() { + // Use summary, similar to "Image" to avoid sending empty quote. + quote.get_summarytext(context, 500).await + } else { + text + }, + ); Ok(()) }