mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
remove additional text parts if we think they belong to a mailinglist footer
This commit is contained in:
@@ -259,6 +259,7 @@ impl MimeMessage {
|
|||||||
};
|
};
|
||||||
parser.parse_mime_recursive(context, &mail).await?;
|
parser.parse_mime_recursive(context, &mail).await?;
|
||||||
parser.maybe_remove_bad_parts();
|
parser.maybe_remove_bad_parts();
|
||||||
|
parser.maybe_remove_inline_mailinglist_footer();
|
||||||
parser.heuristically_parse_ndn(context).await;
|
parser.heuristically_parse_ndn(context).await;
|
||||||
parser.parse_headers(context);
|
parser.parse_headers(context);
|
||||||
|
|
||||||
@@ -1084,6 +1085,28 @@ impl MimeMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove unwanted, additional text parts used for mailing list footer.
|
||||||
|
/// Some mailinglist software add footers as separate mimeparts
|
||||||
|
/// eg. when the user-edited-content is html.
|
||||||
|
/// As these footers would appear as repeated, separate text-bubbles,
|
||||||
|
/// we remove them.
|
||||||
|
fn maybe_remove_inline_mailinglist_footer(&mut self) {
|
||||||
|
if self.is_mailinglist_message() {
|
||||||
|
let text_part_cnt = self
|
||||||
|
.parts
|
||||||
|
.iter()
|
||||||
|
.filter(|p| p.typ == Viewtype::Text)
|
||||||
|
.count();
|
||||||
|
if text_part_cnt == 2 {
|
||||||
|
if let Some(last_part) = self.parts.last() {
|
||||||
|
if last_part.typ == Viewtype::Text {
|
||||||
|
self.parts.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Some providers like GMX and Yahoo do not send standard NDNs (Non Delivery notifications).
|
/// Some providers like GMX and Yahoo do not send standard NDNs (Non Delivery notifications).
|
||||||
/// If you improve heuristics here you might also have to change prefetch_should_download() in imap/mod.rs.
|
/// If you improve heuristics here you might also have to change prefetch_should_download() in imap/mod.rs.
|
||||||
/// Also you should add a test in dc_receive_imf.rs (there already are lots of test_parse_ndn_* tests).
|
/// Also you should add a test in dc_receive_imf.rs (there already are lots of test_parse_ndn_* tests).
|
||||||
|
|||||||
Reference in New Issue
Block a user