From d7c07e0ed349f72846bd357639b699de31239708 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sun, 12 Jan 2020 19:39:29 +0100 Subject: [PATCH] set subject to group-name, tweak prefixes this commit sets the subject of groups to the name of the group. if the message is a reply in the group, also the prefix `Re:` is added. the Chat: prefix is removed for groups, also the Fwd: prefix, as it this would be expected to be set to the group name of the forwarded message, which is not really compatible with the rule "group-name = subject" (forwarded messages are detected by the body, not by the subject) --- src/mimefactory.rs | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 2960cbef1..5c0781f0f 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -327,38 +327,35 @@ impl<'a, 'b> MimeFactory<'a, 'b> { fn subject_str(&self) -> String { match self.loaded { Loaded::Message { ref chat } => { - let raw = message::get_summarytext_by_raw( - self.msg.viewtype, - self.msg.text.as_ref(), - &self.msg.param, - 32, - self.context, - ); - let mut lines = raw.lines(); - let raw_subject = if let Some(line) = lines.next() { - line - } else { - "" - }; - - let afwd_email = self.msg.param.exists(Param::Forwarded); - let fwd = if afwd_email { "Fwd: " } else { "" }; - if self.msg.param.get_cmd() == SystemMessage::AutocryptSetupMessage { - // do not add the "Chat:" prefix for setup messages self.context .stock_str(StockMessage::AcSetupMsgSubject) .into_owned() } else if chat.typ == Chattype::Group || chat.typ == Chattype::VerifiedGroup { - format!("Chat: {}: {}{}", chat.name, fwd, raw_subject) + let re = if self.in_reply_to.is_empty() { + "" + } else { + "Re: " + }; + format!("{}{}", re, chat.name) } else { - format!("Chat: {}{}", fwd, raw_subject) + let raw = message::get_summarytext_by_raw( + self.msg.viewtype, + self.msg.text.as_ref(), + &self.msg.param, + 32, + self.context, + ); + let mut lines = raw.lines(); + let raw_subject = if let Some(line) = lines.next() { + line + } else { + "" + }; + format!("Chat: {}", raw_subject) } } - Loaded::MDN => { - let e = self.context.stock_str(StockMessage::ReadRcpt); - format!("Chat: {}", e) - } + Loaded::MDN => self.context.stock_str(StockMessage::ReadRcpt).into_owned(), } }