feat: Search results display the account email and mailbox name. #39

This commit is contained in:
rustmailer
2025-12-28 13:20:21 +08:00
parent 1f57f372d3
commit a02bb65ca0
4 changed files with 24 additions and 5 deletions
+4
View File
@@ -121,6 +121,8 @@ pub fn extract_envelope(fetch: &Fetch, account_id: u64, mailbox_id: u64) -> Bich
thread_id, thread_id,
attachments, attachments,
tags: None, tags: None,
account_email: None,
mailbox_name: None,
}; };
Ok(envelope) Ok(envelope)
} }
@@ -214,6 +216,8 @@ pub fn extract_envelope_from_eml(
thread_id, thread_id,
attachments, attachments,
tags: None, tags: None,
account_email: None,
mailbox_name: None,
}; };
Ok(envelope) Ok(envelope)
} }
+13 -1
View File
@@ -16,7 +16,8 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
use crate::modules::account::migration::AccountModel;
use crate::modules::cache::imap::mailbox::MailBox;
use crate::modules::error::code::ErrorCode; use crate::modules::error::code::ErrorCode;
use crate::modules::utils::create_hash; use crate::modules::utils::create_hash;
use crate::modules::{error::BichonResult, indexer::schema::SchemaTools}; use crate::modules::{error::BichonResult, indexer::schema::SchemaTools};
@@ -31,7 +32,9 @@ pub struct Envelope {
pub id: u64, pub id: u64,
pub message_id: String, pub message_id: String,
pub account_id: u64, pub account_id: u64,
pub account_email: Option<String>,
pub mailbox_id: u64, pub mailbox_id: u64,
pub mailbox_name: Option<String>,
pub uid: u32, pub uid: u32,
pub subject: String, pub subject: String,
pub text: String, pub text: String,
@@ -169,11 +172,20 @@ impl Envelope {
}) })
.flatten() .flatten()
.collect(); .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 { let envelope = Envelope {
id, id,
account_id, account_id,
account_email,
mailbox_id, mailbox_id,
mailbox_name,
message_id: extract_string_field(doc, fields.f_message_id)?, message_id: extract_string_field(doc, fields.f_message_id)?,
uid: extract_u64_field(doc, fields.f_uid)? as u32, uid: extract_u64_field(doc, fields.f_uid)? as u32,
subject: extract_string_field(doc, fields.f_subject)?, subject: extract_string_field(doc, fields.f_subject)?,
+2
View File
@@ -30,6 +30,8 @@ export interface EmailEnvelope {
id: number; id: number;
message_id: string; message_id: string;
account_id: number; account_id: number;
account_email?: string;
mailbox_name?: string;
uid: number; uid: number;
subject: string; subject: string;
text: string; text: string;
+5 -4
View File
@@ -182,7 +182,6 @@ export function MailList({
<MailIcon className="h-3.5 w-3.5 text-muted-foreground shrink-0" /> <MailIcon className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
<div className="flex-1 min-w-0 grid grid-cols-1 sm:grid-cols-12 gap-1 sm:gap-0"> <div className="flex-1 min-w-0 grid grid-cols-1 sm:grid-cols-12 gap-1 sm:gap-0">
{/* LEFT AREA: From + Subject + Tags */}
<div className="col-span-1 sm:col-span-8 flex flex-col min-w-0 gap-0.5"> <div className="col-span-1 sm:col-span-8 flex flex-col min-w-0 gap-0.5">
<div className="flex items-center gap-1 min-w-0"> <div className="flex items-center gap-1 min-w-0">
<p className="text-sm font-medium truncate">{item.from}</p> <p className="text-sm font-medium truncate">{item.from}</p>
@@ -190,7 +189,11 @@ export function MailList({
{item.subject} {item.subject}
</h3> </h3>
</div> </div>
<div className="flex items-center gap-1.5 text-[10px] text-muted-foreground/60">
<span className="truncate">{item.account_email}</span>
<span className="scale-75 opacity-50"></span>
<span className="font-medium text-primary/70">{item.mailbox_name}</span>
</div>
<h3 className="text-sm text-muted-foreground truncate sm:hidden"> <h3 className="text-sm text-muted-foreground truncate sm:hidden">
{item.subject} {item.subject}
</h3> </h3>
@@ -201,8 +204,6 @@ export function MailList({
))} ))}
</div> </div>
</div> </div>
{/* RIGHT AREA actions & meta */}
<div className="col-span-1 sm:col-span-4 flex items-center justify-end gap-1 text-xs text-muted-foreground"> <div className="col-span-1 sm:col-span-4 flex items-center justify-end gap-1 text-xs text-muted-foreground">
{hasAttachments && ( {hasAttachments && (