fix: Inline attachments are not counted as attachments and are not shown when searching for emails with attachments.

This commit is contained in:
rustmailer
2026-01-06 16:28:55 +08:00
parent d334a23ca7
commit 0c46432150
3 changed files with 13 additions and 4 deletions
+1 -3
View File
@@ -180,7 +180,7 @@ mod tests {
#[test]
fn many_small_mails() {
let mut data = Vec::new();
for i in 0..1000 {
for _ in 0..1000 {
data.extend_from_slice(b"From a\nx\n");
}
let e = collect_entries(&data);
@@ -203,8 +203,6 @@ mod tests {
determine_folder(labels)
)
}
}
}
+12
View File
@@ -100,6 +100,12 @@ pub fn extract_envelope(fetch: &Fetch, account_id: u64, mailbox_id: u64) -> Bich
let attachments: Vec<String> = message
.attachments()
.filter(|att| {
let disp = att.content_disposition();
let is_inline = disp.map(|d| d.is_inline()).unwrap_or(false);
let has_filename = att.attachment_name().is_some();
has_filename && !is_inline
})
.filter_map(|att| att.attachment_name())
.map(|name| name.to_string())
.collect();
@@ -195,6 +201,12 @@ pub fn extract_envelope_from_eml(
let attachments: Vec<String> = message
.attachments()
.filter(|att| {
let disp = att.content_disposition();
let is_inline = disp.map(|d| d.is_inline()).unwrap_or(false);
let has_filename = att.attachment_name().is_some();
has_filename && !is_inline
})
.filter_map(|att| att.attachment_name())
.map(|name| name.to_string())
.collect();
-1
View File
@@ -100,7 +100,6 @@ impl ImportEmls {
let total = request.emls.len();
for (index, eml_base64) in request.emls.into_iter().enumerate() {
// 1. Decode Base64
let decoded = match base64_decode_url_safe!(eml_base64.as_bytes()) {
Ok(bytes) => bytes,
Err(e) => {