web & server: improved debug printing of unhandled mime types
This commit is contained in:
parent
11366b6fac
commit
1261bdf8a9
@ -246,7 +246,10 @@ impl QueryRoot {
|
|||||||
"text/plain" => Body::PlainText(PlainText { text: body }),
|
"text/plain" => Body::PlainText(PlainText { text: body }),
|
||||||
"text/html" => Body::Html(Html { html: body }),
|
"text/html" => Body::Html(Html { html: body }),
|
||||||
_ => {
|
_ => {
|
||||||
let msg = format!("Unhandled body content type: {}", m.ctype.mimetype);
|
let msg = format!(
|
||||||
|
"Unhandled body content type:\n{}",
|
||||||
|
render_content_type_tree(&m)
|
||||||
|
);
|
||||||
warn!("{}", msg);
|
warn!("{}", msg);
|
||||||
Body::UnhandledContentType(UnhandledContentType { text: msg })
|
Body::UnhandledContentType(UnhandledContentType { text: msg })
|
||||||
}
|
}
|
||||||
@ -273,6 +276,31 @@ impl QueryRoot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_content_type_tree(m: &ParsedMail) -> String {
|
||||||
|
const WIDTH: usize = 4;
|
||||||
|
fn render_rec(m: &ParsedMail, depth: usize) -> String {
|
||||||
|
let mut parts = Vec::new();
|
||||||
|
let msg = format!("{} {}", "-".repeat(depth * WIDTH), m.ctype.mimetype);
|
||||||
|
println!("{msg}",);
|
||||||
|
parts.push(msg);
|
||||||
|
if !m.ctype.charset.is_empty() {
|
||||||
|
parts.push(format!(
|
||||||
|
"{} Character Set: {}",
|
||||||
|
" ".repeat(depth * WIDTH),
|
||||||
|
m.ctype.charset
|
||||||
|
));
|
||||||
|
}
|
||||||
|
for (k, v) in m.ctype.params.iter() {
|
||||||
|
parts.push(format!("{} {k}: {v}", " ".repeat(depth * WIDTH),));
|
||||||
|
}
|
||||||
|
for sp in &m.subparts {
|
||||||
|
parts.push(render_rec(sp, depth + 1))
|
||||||
|
}
|
||||||
|
parts.join("\n")
|
||||||
|
}
|
||||||
|
render_rec(m, 1)
|
||||||
|
}
|
||||||
|
|
||||||
pub type GraphqlSchema = Schema<QueryRoot, EmptyMutation, EmptySubscription>;
|
pub type GraphqlSchema = Schema<QueryRoot, EmptyMutation, EmptySubscription>;
|
||||||
|
|
||||||
fn email_addresses(path: &str, m: &ParsedMail, header_name: &str) -> Result<Vec<Email>, Error> {
|
fn email_addresses(path: &str, m: &ParsedMail, header_name: &str) -> Result<Vec<Email>, Error> {
|
||||||
|
|||||||
@ -1059,7 +1059,7 @@ fn view_thread(thread: &ShowThreadQueryThread) -> Node<Msg> {
|
|||||||
match &msg.body {
|
match &msg.body {
|
||||||
ShowThreadQueryThreadMessagesBody::UnhandledContentType(
|
ShowThreadQueryThreadMessagesBody::UnhandledContentType(
|
||||||
ShowThreadQueryThreadMessagesBodyOnUnhandledContentType { contents },
|
ShowThreadQueryThreadMessagesBodyOnUnhandledContentType { contents },
|
||||||
) => div![C!["error"], contents],
|
) => pre![C!["error"], contents],
|
||||||
ShowThreadQueryThreadMessagesBody::PlainText(
|
ShowThreadQueryThreadMessagesBody::PlainText(
|
||||||
ShowThreadQueryThreadMessagesBodyOnPlainText { contents },
|
ShowThreadQueryThreadMessagesBodyOnPlainText { contents },
|
||||||
) => div![C!["view-part-text-plain"], contents],
|
) => div![C!["view-part-text-plain"], contents],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user