From fa98f161c627b761c0fc14563e07711fe4415a3c Mon Sep 17 00:00:00 2001 From: sripwoud Date: Tue, 18 Aug 2026 21:59:34 +0200 Subject: [PATCH] fix(core): carry duplicates through the import audit event success no longer includes dedup-skipped mail, so without a duplicates field ImportPerformed consumers could not tell an all-duplicates batch from one that silently lost everything. Also documents that ExtractOutcome::Imported covers mail dropped by archive rules, which has always counted as a success. --- crates/core/src/envelope/extractor.rs | 6 ++++-- crates/core/src/ext/event_bus.rs | 1 + crates/server/src/rest/api/import.rs | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/core/src/envelope/extractor.rs b/crates/core/src/envelope/extractor.rs index 71c2dc3..9ee3294 100644 --- a/crates/core/src/envelope/extractor.rs +++ b/crates/core/src/envelope/extractor.rs @@ -46,8 +46,10 @@ use crate::{ utils::{compute_content_hash, hex_hash, html::extract_text}, }; -/// The outcome of extracting an envelope: either the message was imported, -/// or it was skipped because its content hash was already archived. +/// The outcome of extracting an envelope. `Duplicate` means the message was +/// skipped because its content hash was already archived. `Imported` covers +/// every other processed message, including mail dropped by archive rules, +/// which has always counted as a success on the import surfaces. #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[must_use] pub enum ExtractOutcome { diff --git a/crates/core/src/ext/event_bus.rs b/crates/core/src/ext/event_bus.rs index 08c51d7..d4c4845 100644 --- a/crates/core/src/ext/event_bus.rs +++ b/crates/core/src/ext/event_bus.rs @@ -209,6 +209,7 @@ pub enum Event { format: String, total: u64, success: u64, + duplicates: u64, failed: u64, }, MailboxRemoved { diff --git a/crates/server/src/rest/api/import.rs b/crates/server/src/rest/api/import.rs index 44253aa..4ff2e25 100644 --- a/crates/server/src/rest/api/import.rs +++ b/crates/server/src/rest/api/import.rs @@ -77,6 +77,7 @@ impl ImportApi { format: "eml".to_string(), total: result.total as u64, success: result.success as u64, + duplicates: result.duplicates as u64, failed: result.failed as u64, }); @@ -274,6 +275,7 @@ impl ImportApi { format: format_str.clone(), total: 0, success: 0, + duplicates: 0, failed: 0, }); tokio::task::spawn_blocking(move || {