From a02bb65ca0d07f0c88c37ce784cfc695235ea163 Mon Sep 17 00:00:00 2001 From: rustmailer Date: Sun, 28 Dec 2025 13:20:21 +0800 Subject: [PATCH] feat: Search results display the account email and mailbox name. #39 --- src/modules/envelope/extractor.rs | 4 ++++ src/modules/indexer/envelope.rs | 14 +++++++++++++- web/src/api/index.ts | 2 ++ web/src/features/search/mail-list.tsx | 9 +++++---- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/modules/envelope/extractor.rs b/src/modules/envelope/extractor.rs index 59b565a..339ce9d 100644 --- a/src/modules/envelope/extractor.rs +++ b/src/modules/envelope/extractor.rs @@ -121,6 +121,8 @@ pub fn extract_envelope(fetch: &Fetch, account_id: u64, mailbox_id: u64) -> Bich thread_id, attachments, tags: None, + account_email: None, + mailbox_name: None, }; Ok(envelope) } @@ -214,6 +216,8 @@ pub fn extract_envelope_from_eml( thread_id, attachments, tags: None, + account_email: None, + mailbox_name: None, }; Ok(envelope) } diff --git a/src/modules/indexer/envelope.rs b/src/modules/indexer/envelope.rs index 4007fbf..e89c65d 100644 --- a/src/modules/indexer/envelope.rs +++ b/src/modules/indexer/envelope.rs @@ -16,7 +16,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - +use crate::modules::account::migration::AccountModel; +use crate::modules::cache::imap::mailbox::MailBox; use crate::modules::error::code::ErrorCode; use crate::modules::utils::create_hash; use crate::modules::{error::BichonResult, indexer::schema::SchemaTools}; @@ -31,7 +32,9 @@ pub struct Envelope { pub id: u64, pub message_id: String, pub account_id: u64, + pub account_email: Option, pub mailbox_id: u64, + pub mailbox_name: Option, pub uid: u32, pub subject: String, pub text: String, @@ -169,11 +172,20 @@ impl Envelope { }) .flatten() .collect(); + let account_email = AccountModel::find(account_id).await?.map(|a| a.email); + + let mailboxes = MailBox::list_all(account_id).await?; + let mailbox_name = mailboxes + .iter() + .find(|m| m.id == mailbox_id) + .map(|m| m.name.clone()); let envelope = Envelope { id, account_id, + account_email, mailbox_id, + mailbox_name, message_id: extract_string_field(doc, fields.f_message_id)?, uid: extract_u64_field(doc, fields.f_uid)? as u32, subject: extract_string_field(doc, fields.f_subject)?, diff --git a/web/src/api/index.ts b/web/src/api/index.ts index db468d7..b0e6a6c 100644 --- a/web/src/api/index.ts +++ b/web/src/api/index.ts @@ -30,6 +30,8 @@ export interface EmailEnvelope { id: number; message_id: string; account_id: number; + account_email?: string; + mailbox_name?: string; uid: number; subject: string; text: string; diff --git a/web/src/features/search/mail-list.tsx b/web/src/features/search/mail-list.tsx index e62b2ea..8ed08ac 100644 --- a/web/src/features/search/mail-list.tsx +++ b/web/src/features/search/mail-list.tsx @@ -182,7 +182,6 @@ export function MailList({
- {/* LEFT AREA: From + Subject + Tags */}

{item.from}

@@ -190,7 +189,11 @@ export function MailList({ {item.subject}
- +
+ {item.account_email} + + {item.mailbox_name} +

{item.subject}

@@ -201,8 +204,6 @@ export function MailList({ ))}
- - {/* RIGHT AREA – actions & meta */}
{hasAttachments && (