mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
mimefactory: refactor generation of the To: field
Group all the code responsible for the generation of the To: field
This commit is contained in:
@@ -458,8 +458,20 @@ impl<'a> MimeFactory<'a> {
|
|||||||
self.from_addr.clone(),
|
self.from_addr.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let undisclosed_recipients = match &self.loaded {
|
||||||
|
Loaded::Message { chat } => chat.typ == Chattype::Broadcast,
|
||||||
|
Loaded::Mdn { .. } => false,
|
||||||
|
};
|
||||||
|
|
||||||
let mut to = Vec::new();
|
let mut to = Vec::new();
|
||||||
let email_to_remove = if self.msg.param.get_cmd() == SystemMessage::MemberRemovedFromGroup {
|
if undisclosed_recipients {
|
||||||
|
to.push(Address::new_group(
|
||||||
|
"hidden-recipients".to_string(),
|
||||||
|
Vec::new(),
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
let email_to_remove =
|
||||||
|
if self.msg.param.get_cmd() == SystemMessage::MemberRemovedFromGroup {
|
||||||
self.msg.param.get(Param::Arg)
|
self.msg.param.get(Param::Arg)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@@ -485,6 +497,7 @@ impl<'a> MimeFactory<'a> {
|
|||||||
if to.is_empty() {
|
if to.is_empty() {
|
||||||
to.push(from.clone());
|
to.push(from.clone());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
headers
|
headers
|
||||||
.unprotected
|
.unprotected
|
||||||
@@ -584,20 +597,9 @@ impl<'a> MimeFactory<'a> {
|
|||||||
render_rfc724_mid(&rfc724_mid),
|
render_rfc724_mid(&rfc724_mid),
|
||||||
));
|
));
|
||||||
|
|
||||||
let undisclosed_recipients = match &self.loaded {
|
|
||||||
Loaded::Message { chat } => chat.typ == Chattype::Broadcast,
|
|
||||||
Loaded::Mdn { .. } => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
if undisclosed_recipients {
|
|
||||||
headers
|
|
||||||
.unprotected
|
|
||||||
.push(Header::new("To".into(), "hidden-recipients: ;".to_string()));
|
|
||||||
} else {
|
|
||||||
headers
|
headers
|
||||||
.unprotected
|
.unprotected
|
||||||
.push(Header::new_with_value("To".into(), to).unwrap());
|
.push(Header::new_with_value("To".into(), to).unwrap());
|
||||||
}
|
|
||||||
|
|
||||||
headers
|
headers
|
||||||
.unprotected
|
.unprotected
|
||||||
|
|||||||
Reference in New Issue
Block a user