diff --git a/server/src/graphql.rs b/server/src/graphql.rs index e1ccdd3..59e2796 100644 --- a/server/src/graphql.rs +++ b/server/src/graphql.rs @@ -3,6 +3,7 @@ use std::{ collections::HashMap, fs::File, hash::{DefaultHasher, Hash, Hasher}, + time::Instant, }; use async_graphql::{ @@ -13,7 +14,6 @@ use log::{error, info, warn}; use mailparse::{parse_mail, MailHeader, MailHeaderMap, ParsedMail}; use memmap::MmapOptions; use notmuch::Notmuch; -use rocket::time::Instant; use crate::{error::ServerError, linkify_html, sanitize_html}; @@ -298,7 +298,7 @@ impl QueryRoot { } }) .collect(); - info!("Fetching tags took {}", now.elapsed()); + info!("Fetching tags took {} seconds", now.elapsed().as_secs_f32()); Ok(tags) } async fn thread<'ctx>(&self, ctx: &Context<'ctx>, thread_id: String) -> Result { @@ -390,7 +390,6 @@ impl QueryRoot { }, }) } - b => b, }; let headers = m .headers @@ -527,11 +526,12 @@ fn extract_body(m: &ParsedMail, id: &str) -> Result { fn extract_unhandled(m: &ParsedMail) -> Result { let msg = format!( - "Unhandled body content type:\n{}", - render_content_type_tree(m) + "Unhandled body content type:\n{}\n{}", + render_content_type_tree(m), + m.get_body()?, ); Ok(Body::UnhandledContentType(UnhandledContentType { - text: m.get_body()?, + text: msg, content_tree: render_content_type_tree(m), })) } @@ -804,7 +804,7 @@ fn extract_attachment(m: &ParsedMail, id: &str, idx: &[usize]) -> Option &str { +pub fn get_attachment_filename(header_value: &str) -> &str { info!("get_attachment_filename {header_value}"); // Strip last " let v = &header_value[..header_value.len() - 1]; @@ -815,7 +815,7 @@ fn get_attachment_filename(header_value: &str) -> &str { } } -fn get_content_type<'a>(headers: &[MailHeader<'a>]) -> Option { +pub fn get_content_type<'a>(headers: &[MailHeader<'a>]) -> Option { if let Some(v) = headers.get_first_value("Content-Type") { if let Some(idx) = v.find(';') { return Some(v[..idx].to_string()); @@ -936,7 +936,7 @@ pub fn cid_attachment_bytes(nm: &Notmuch, id: &str, cid: &str) -> Result