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)
This commit is contained in:
B. Petersen
2020-01-12 19:39:29 +01:00
committed by holger krekel
parent 08bd16c1b6
commit d7c07e0ed3

View File

@@ -327,6 +327,18 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
fn subject_str(&self) -> String { fn subject_str(&self) -> String {
match self.loaded { match self.loaded {
Loaded::Message { ref chat } => { Loaded::Message { ref chat } => {
if self.msg.param.get_cmd() == SystemMessage::AutocryptSetupMessage {
self.context
.stock_str(StockMessage::AcSetupMsgSubject)
.into_owned()
} else if chat.typ == Chattype::Group || chat.typ == Chattype::VerifiedGroup {
let re = if self.in_reply_to.is_empty() {
""
} else {
"Re: "
};
format!("{}{}", re, chat.name)
} else {
let raw = message::get_summarytext_by_raw( let raw = message::get_summarytext_by_raw(
self.msg.viewtype, self.msg.viewtype,
self.msg.text.as_ref(), self.msg.text.as_ref(),
@@ -340,25 +352,10 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
} else { } else {
"" ""
}; };
format!("Chat: {}", raw_subject)
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)
} else {
format!("Chat: {}{}", fwd, raw_subject)
} }
} }
Loaded::MDN => { Loaded::MDN => self.context.stock_str(StockMessage::ReadRcpt).into_owned(),
let e = self.context.stock_str(StockMessage::ReadRcpt);
format!("Chat: {}", e)
}
} }
} }