Compare commits
4 Commits
76ef9919ce
...
751267ec43
| Author | SHA1 | Date | |
|---|---|---|---|
| 751267ec43 | |||
| 17ad5b3b0b | |||
| 285b2f1591 | |||
| 1537333e76 |
251
Cargo.lock
generated
251
Cargo.lock
generated
@ -693,20 +693,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e232cc6fad4ac9f969bba34440da4d45947a55e60008fbaf5342163f30d6d34"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"build-info-common",
|
||||
"build-info-proc",
|
||||
"build-info-common 0.0.41",
|
||||
"build-info-proc 0.0.41",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build-info"
|
||||
version = "0.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "362b762d8ad3063c57f02a3a94bc6814aee11d09c7e4d8b31fefb34d4731a611"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"build-info-common 0.0.42",
|
||||
"build-info-proc 0.0.42",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build-info-build"
|
||||
version = "0.0.41"
|
||||
version = "0.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c095501b4684e681005757c3171fccf3b8a4132a8cf8e5135b6a885068cd413e"
|
||||
checksum = "3b090e1d116997848529faaf849e1efd592cbe6e9eb44623c0588f017c63bbc4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
"bincode",
|
||||
"build-info-common",
|
||||
"build-info-common 0.0.42",
|
||||
"cargo_metadata",
|
||||
"chrono",
|
||||
"git2",
|
||||
@ -729,6 +740,18 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build-info-common"
|
||||
version = "0.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7a436965b6554ae18aba994745234bf2ed98d2c984e96b58aeb0f845c666969"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"derive_more",
|
||||
"semver 1.0.27",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build-info-proc"
|
||||
version = "0.0.41"
|
||||
@ -738,7 +761,28 @@ dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
"bincode",
|
||||
"build-info-common",
|
||||
"build-info-common 0.0.41",
|
||||
"chrono",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
"proc-macro-error2",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde_json",
|
||||
"syn 2.0.107",
|
||||
"zstd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build-info-proc"
|
||||
version = "0.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "163d30dc69f05b7bd0ae944539f8bd292607e10471ad5b4b3ab849da24e582f3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
"bincode",
|
||||
"build-info-common 0.0.42",
|
||||
"chrono",
|
||||
"num-bigint",
|
||||
"num-traits",
|
||||
@ -839,38 +883,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cargo-platform"
|
||||
version = "0.2.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84982c6c0ae343635a3a4ee6dedef965513735c8b183caa7289fa6e27399ebd4"
|
||||
checksum = "122ec45a44b270afd1402f351b782c676b173e3c3fb28d86ff7ebfb4d86a4ee4"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo-util-schemas"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e63d2780ac94487eb9f1fea7b0d56300abc9eb488800854ca217f102f5caccca"
|
||||
dependencies = [
|
||||
"semver 1.0.27",
|
||||
"serde",
|
||||
"serde-untagged",
|
||||
"serde-value",
|
||||
"thiserror 1.0.69",
|
||||
"toml",
|
||||
"unicode-xid",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.20.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f7835cfc6135093070e95eb2b53e5d9b5c403dc3a6be6040ee026270aa82502"
|
||||
checksum = "981a6f317983eec002839b90fae7411a85621410ae591a9cab2ecf5cb5744873"
|
||||
dependencies = [
|
||||
"camino",
|
||||
"cargo-platform",
|
||||
"cargo-util-schemas",
|
||||
"semver 1.0.27",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -959,9 +986,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.49"
|
||||
version = "4.5.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4512b90fa68d3a9932cea5184017c5d200f5921df706d45e853537dea51508f"
|
||||
checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
@ -969,9 +996,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.49"
|
||||
version = "4.5.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0025e98baa12e766c67ba13ff4695a887a1eba19569aad00a472546795bd6730"
|
||||
checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
@ -1688,17 +1715,6 @@ version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
|
||||
[[package]]
|
||||
name = "erased-serde"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "259d404d09818dec19332e31d94558aeb442fea04c817006456c24b5460bbd4b"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_core",
|
||||
"typeid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.14"
|
||||
@ -3131,6 +3147,20 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "letterbox-notmuch"
|
||||
version = "0.17.44"
|
||||
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
|
||||
checksum = "c134bb4ba84b2d44a2e4fce8369edc2c5a32bd7e00a4a32b2c179148ab4251b2"
|
||||
dependencies = [
|
||||
"log",
|
||||
"mailparse",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-notmuch"
|
||||
version = "0.17.45"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"log",
|
||||
@ -3143,28 +3173,14 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-notmuch"
|
||||
version = "0.17.44"
|
||||
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
|
||||
checksum = "c134bb4ba84b2d44a2e4fce8369edc2c5a32bd7e00a4a32b2c179148ab4251b2"
|
||||
dependencies = [
|
||||
"log",
|
||||
"mailparse",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.17",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-procmail2notmuch"
|
||||
version = "0.17.44"
|
||||
version = "0.17.45"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"letterbox-notmuch 0.17.44 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
|
||||
"letterbox-shared 0.17.44 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
|
||||
"letterbox-notmuch 0.17.44",
|
||||
"letterbox-shared 0.17.44",
|
||||
"serde",
|
||||
"sqlx",
|
||||
"tokio 1.48.0",
|
||||
@ -3172,7 +3188,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-server"
|
||||
version = "0.17.44"
|
||||
version = "0.17.45"
|
||||
dependencies = [
|
||||
"ammonia",
|
||||
"anyhow",
|
||||
@ -3182,7 +3198,7 @@ dependencies = [
|
||||
"async-trait",
|
||||
"axum 0.8.6",
|
||||
"axum-macros",
|
||||
"build-info",
|
||||
"build-info 0.0.42",
|
||||
"build-info-build",
|
||||
"cacher",
|
||||
"chrono",
|
||||
@ -3195,8 +3211,8 @@ dependencies = [
|
||||
"html-escape",
|
||||
"html2text",
|
||||
"ical",
|
||||
"letterbox-notmuch 0.17.44",
|
||||
"letterbox-shared 0.17.44",
|
||||
"letterbox-notmuch 0.17.45",
|
||||
"letterbox-shared 0.17.45",
|
||||
"linkify",
|
||||
"lol_html",
|
||||
"mailparse",
|
||||
@ -3223,8 +3239,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "letterbox-shared"
|
||||
version = "0.17.44"
|
||||
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
|
||||
checksum = "6b56f113a3e37cf56af9a73c180689661cf5a501262feb45b518b6ddcd0daaaf"
|
||||
dependencies = [
|
||||
"build-info",
|
||||
"build-info 0.0.41",
|
||||
"letterbox-notmuch 0.17.44",
|
||||
"regex",
|
||||
"serde",
|
||||
@ -3235,12 +3253,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-shared"
|
||||
version = "0.17.44"
|
||||
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
|
||||
checksum = "6b56f113a3e37cf56af9a73c180689661cf5a501262feb45b518b6ddcd0daaaf"
|
||||
version = "0.17.45"
|
||||
dependencies = [
|
||||
"build-info",
|
||||
"letterbox-notmuch 0.17.44 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
|
||||
"build-info 0.0.42",
|
||||
"letterbox-notmuch 0.17.45",
|
||||
"regex",
|
||||
"serde",
|
||||
"sqlx",
|
||||
@ -3250,9 +3266,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "letterbox-web"
|
||||
version = "0.17.44"
|
||||
version = "0.17.45"
|
||||
dependencies = [
|
||||
"build-info",
|
||||
"build-info 0.0.42",
|
||||
"build-info-build",
|
||||
"chrono",
|
||||
"console_error_panic_hook",
|
||||
@ -3262,7 +3278,7 @@ dependencies = [
|
||||
"graphql_client",
|
||||
"human_format",
|
||||
"itertools",
|
||||
"letterbox-shared 0.17.44",
|
||||
"letterbox-shared 0.17.45",
|
||||
"log",
|
||||
"seed",
|
||||
"seed_hooks",
|
||||
@ -4020,15 +4036,6 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "2.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ownedbytes"
|
||||
version = "0.9.0"
|
||||
@ -4392,7 +4399,7 @@ version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983"
|
||||
dependencies = [
|
||||
"toml_edit 0.23.7",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -5337,28 +5344,6 @@ dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-untagged"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9faf48a4a2d2693be24c6289dbe26552776eb7737074e6722891fadbe6c5058"
|
||||
dependencies = [
|
||||
"erased-serde",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"typeid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-value"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
|
||||
dependencies = [
|
||||
"ordered-float",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-wasm-bindgen"
|
||||
version = "0.5.0"
|
||||
@ -5414,15 +5399,6 @@ dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.7.1"
|
||||
@ -6600,27 +6576,6 @@ dependencies = [
|
||||
"tokio 1.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime 0.6.11",
|
||||
"toml_edit 0.22.27",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.7.3"
|
||||
@ -6630,20 +6585,6 @@ dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
|
||||
dependencies = [
|
||||
"indexmap 2.12.0",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime 0.6.11",
|
||||
"toml_write",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.23.7"
|
||||
@ -6651,7 +6592,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d"
|
||||
dependencies = [
|
||||
"indexmap 2.12.0",
|
||||
"toml_datetime 0.7.3",
|
||||
"toml_datetime",
|
||||
"toml_parser",
|
||||
"winnow",
|
||||
]
|
||||
@ -6665,12 +6606,6 @@ dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_write"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
|
||||
|
||||
[[package]]
|
||||
name = "tonic"
|
||||
version = "0.12.3"
|
||||
@ -6909,12 +6844,6 @@ dependencies = [
|
||||
"utf-8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typeid"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c"
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.19.0"
|
||||
|
||||
@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
|
||||
edition = "2021"
|
||||
license = "UNLICENSED"
|
||||
publish = ["xinu"]
|
||||
version = "0.17.44"
|
||||
version = "0.17.45"
|
||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||
|
||||
[profile.dev]
|
||||
|
||||
@ -22,7 +22,7 @@ async-graphql-axum = "7.0.16"
|
||||
async-trait = "0.1.88"
|
||||
axum = { version = "0.8.3", features = ["ws"] }
|
||||
axum-macros = "0.5.0"
|
||||
build-info = "0.0.41"
|
||||
build-info = "0.0.42"
|
||||
cacher = { version = "0.2.0", registry = "xinu" }
|
||||
chrono = "0.4.40"
|
||||
clap = { version = "4.5.37", features = ["derive"] }
|
||||
@ -32,8 +32,8 @@ futures = "0.3.31"
|
||||
headers = "0.4.0"
|
||||
html-escape = "0.2.13"
|
||||
ical = "0.11"
|
||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.44", registry = "xinu" }
|
||||
letterbox-shared = { path = "../shared", version = "0.17.44", registry = "xinu" }
|
||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.45", registry = "xinu" }
|
||||
letterbox-shared = { path = "../shared", version = "0.17.45", registry = "xinu" }
|
||||
linkify = "0.10.0"
|
||||
lol_html = "2.3.0"
|
||||
mailparse = "0.16.1"
|
||||
@ -60,7 +60,7 @@ zip = "5.0.0"
|
||||
|
||||
|
||||
[build-dependencies]
|
||||
build-info-build = "0.0.41"
|
||||
build-info-build = "0.0.42"
|
||||
|
||||
[features]
|
||||
#default = [ "tantivy" ]
|
||||
|
||||
@ -17,9 +17,11 @@ use crate::{
|
||||
const APPLICATION_GZIP: &'static str = "application/gzip";
|
||||
|
||||
const APPLICATION_ZIP: &'static str = "application/zip";
|
||||
const APPLICATION_TLSRPT_GZIP: &'static str = "application/tlsrpt+gzip";
|
||||
const IMAGE_JPEG: &'static str = "image/jpeg";
|
||||
const IMAGE_PJPEG: &'static str = "image/pjpeg";
|
||||
const IMAGE_PNG: &'static str = "image/png";
|
||||
const MESSAGE_DELIVERY_STATUS: &'static str = "message/delivery-status";
|
||||
const MESSAGE_RFC822: &'static str = "message/rfc822";
|
||||
const MULTIPART_ALTERNATIVE: &'static str = "multipart/alternative";
|
||||
const MULTIPART_MIXED: &'static str = "multipart/mixed";
|
||||
@ -641,115 +643,186 @@ pub fn extract_gzip(m: &ParsedMail) -> Result<(Body, Option<String>), ServerErro
|
||||
Ok((extract_unhandled(m)?, None))
|
||||
}
|
||||
|
||||
pub fn extract_report(m: &ParsedMail, _part_addr: &mut Vec<String>) -> Result<Body, ServerError> {
|
||||
let mut html_part = None;
|
||||
let mut tlsrpt_part = None;
|
||||
pub fn extract_report(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Body, ServerError> {
|
||||
let mut parts = Vec::new();
|
||||
|
||||
for (idx, sp) in m.subparts.iter().enumerate() {
|
||||
part_addr.push(idx.to_string());
|
||||
|
||||
for sp in &m.subparts {
|
||||
match sp.ctype.mimetype.as_str() {
|
||||
TEXT_HTML => html_part = Some(sp.get_body()?),
|
||||
"application/tlsrpt+gzip" => tlsrpt_part = Some(sp.get_body_raw()?),
|
||||
_ => {} // Ignore other parts for now
|
||||
}
|
||||
}
|
||||
|
||||
let tlsrpt_summary_html = if let Some(gz_bytes) = tlsrpt_part {
|
||||
let mut decoder = flate2::read::GzDecoder::new(&gz_bytes[..]);
|
||||
let mut buffer = Vec::new();
|
||||
if decoder.read_to_end(&mut buffer).is_ok() {
|
||||
if let Ok(json_str) = String::from_utf8(buffer) {
|
||||
match serde_json::from_str::<TlsRpt>(&json_str) {
|
||||
Ok(tlsrpt) => {
|
||||
let formatted_tlsrpt = FormattedTlsRpt {
|
||||
organization_name: tlsrpt.organization_name,
|
||||
date_range: FormattedTlsRptDateRange {
|
||||
start_datetime: tlsrpt.date_range.start_datetime,
|
||||
end_datetime: tlsrpt.date_range.end_datetime,
|
||||
},
|
||||
contact_info: tlsrpt.contact_info.unwrap_or_else(|| "".to_string()),
|
||||
report_id: tlsrpt.report_id,
|
||||
policies: tlsrpt
|
||||
.policies
|
||||
.into_iter()
|
||||
.map(|policy| FormattedTlsRptPolicy {
|
||||
policy: FormattedTlsRptPolicyDetails {
|
||||
policy_type: policy.policy.policy_type,
|
||||
policy_string: policy.policy.policy_string,
|
||||
policy_domain: policy.policy.policy_domain,
|
||||
mx_host: policy
|
||||
.policy
|
||||
.mx_host
|
||||
.unwrap_or_else(|| Vec::new())
|
||||
.into_iter()
|
||||
.map(|mx| match mx {
|
||||
MxHost::String(s) => FormattedTlsRptMxHost {
|
||||
hostname: s,
|
||||
failure_count: 0,
|
||||
result_type: "".to_string(),
|
||||
},
|
||||
MxHost::Object(o) => FormattedTlsRptMxHost {
|
||||
hostname: o.hostname,
|
||||
failure_count: o.failure_count,
|
||||
result_type: o.result_type,
|
||||
},
|
||||
})
|
||||
.collect(),
|
||||
APPLICATION_TLSRPT_GZIP => {
|
||||
let gz_bytes = sp.get_body_raw()?;
|
||||
let mut decoder = flate2::read::GzDecoder::new(&gz_bytes[..]);
|
||||
let mut buffer = Vec::new();
|
||||
if decoder.read_to_end(&mut buffer).is_ok() {
|
||||
if let Ok(json_str) = String::from_utf8(buffer) {
|
||||
match serde_json::from_str::<TlsRpt>(&json_str) {
|
||||
Ok(tlsrpt) => {
|
||||
let formatted_tlsrpt = FormattedTlsRpt {
|
||||
organization_name: tlsrpt.organization_name,
|
||||
date_range: FormattedTlsRptDateRange {
|
||||
start_datetime: tlsrpt.date_range.start_datetime,
|
||||
end_datetime: tlsrpt.date_range.end_datetime,
|
||||
},
|
||||
summary: policy.summary,
|
||||
failure_details: policy
|
||||
.failure_details
|
||||
.unwrap_or_else(|| Vec::new())
|
||||
contact_info: tlsrpt
|
||||
.contact_info
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
report_id: tlsrpt.report_id,
|
||||
policies: tlsrpt
|
||||
.policies
|
||||
.into_iter()
|
||||
.map(|detail| FormattedTlsRptFailureDetails {
|
||||
result_type: detail.result_type,
|
||||
sending_mta_ip: detail
|
||||
.sending_mta_ip
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
receiving_ip: detail
|
||||
.receiving_ip
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
receiving_mx_hostname: detail
|
||||
.receiving_mx_hostname
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
failed_session_count: detail.failed_session_count,
|
||||
additional_info: detail
|
||||
.additional_info
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
failure_reason_code: detail
|
||||
.failure_reason_code
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
.map(|policy| FormattedTlsRptPolicy {
|
||||
policy: FormattedTlsRptPolicyDetails {
|
||||
policy_type: policy.policy.policy_type,
|
||||
policy_string: policy.policy.policy_string,
|
||||
policy_domain: policy.policy.policy_domain,
|
||||
mx_host: policy
|
||||
.policy
|
||||
.mx_host
|
||||
.unwrap_or_else(|| Vec::new())
|
||||
.into_iter()
|
||||
.map(|mx| match mx {
|
||||
MxHost::String(s) => {
|
||||
FormattedTlsRptMxHost {
|
||||
hostname: s,
|
||||
failure_count: 0,
|
||||
result_type: "".to_string(),
|
||||
}
|
||||
}
|
||||
MxHost::Object(o) => {
|
||||
FormattedTlsRptMxHost {
|
||||
hostname: o.hostname,
|
||||
failure_count: o.failure_count,
|
||||
result_type: o.result_type,
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
summary: policy.summary,
|
||||
failure_details: policy
|
||||
.failure_details
|
||||
.unwrap_or_else(|| Vec::new())
|
||||
.into_iter()
|
||||
.map(|detail| FormattedTlsRptFailureDetails {
|
||||
result_type: detail.result_type,
|
||||
sending_mta_ip: detail
|
||||
.sending_mta_ip
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
receiving_ip: detail
|
||||
.receiving_ip
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
receiving_mx_hostname: detail
|
||||
.receiving_mx_hostname
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
failed_session_count: detail
|
||||
.failed_session_count,
|
||||
additional_info: detail
|
||||
.additional_info
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
failure_reason_code: detail
|
||||
.failure_reason_code
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
.collect(),
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
let template = TlsReportTemplate {
|
||||
report: &formatted_tlsrpt,
|
||||
};
|
||||
template.render().unwrap_or_else(|e| format!("<div class=\"tlsrpt-error\">Failed to render TLS report template: {}</div>", e))
|
||||
};
|
||||
let template = TlsReportTemplate {
|
||||
report: &formatted_tlsrpt,
|
||||
};
|
||||
let html = template.render().unwrap_or_else(|e| format!("<div class=\"tlsrpt-error\">Failed to render TLS report template: {}</div>", e));
|
||||
parts.push(Body::html(html));
|
||||
}
|
||||
Err(e) => {
|
||||
let html = format!(
|
||||
"<div class=\"tlsrpt-error\">Failed to parse TLS report JSON: {}</div>",
|
||||
e
|
||||
);
|
||||
parts.push(Body::html(html));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let html = format!("<div class=\"tlsrpt-error\">Failed to convert decompressed data to UTF-8.</div>");
|
||||
parts.push(Body::html(html));
|
||||
}
|
||||
} else {
|
||||
let html =
|
||||
format!("<div class=\"tlsrpt-error\">Failed to decompress data.</div>");
|
||||
parts.push(Body::html(html));
|
||||
}
|
||||
}
|
||||
MESSAGE_RFC822 => {
|
||||
parts.push(extract_rfc822(&sp, part_addr)?);
|
||||
}
|
||||
TEXT_HTML => {
|
||||
let body = sp.get_body()?;
|
||||
parts.push(Body::html(body));
|
||||
}
|
||||
MESSAGE_DELIVERY_STATUS => {
|
||||
let body = extract_delivery_status(sp)?;
|
||||
parts.push(body);
|
||||
}
|
||||
TEXT_PLAIN => {
|
||||
let body = sp.get_body()?;
|
||||
parts.push(Body::text(body));
|
||||
}
|
||||
_ => {
|
||||
// For any other content type, try to extract the body using the general extract_body function
|
||||
match extract_body(sp, part_addr) {
|
||||
Ok(body) => parts.push(body),
|
||||
Err(_) => {
|
||||
// If extraction fails, create an unhandled content type body
|
||||
let msg = format!(
|
||||
"Unhandled report subpart content type: {}\n{}",
|
||||
sp.ctype.mimetype,
|
||||
sp.get_body()
|
||||
.unwrap_or_else(|_| "Failed to get body".to_string())
|
||||
);
|
||||
parts.push(Body::UnhandledContentType(UnhandledContentType {
|
||||
text: msg,
|
||||
content_tree: render_content_type_tree(sp),
|
||||
}));
|
||||
}
|
||||
Err(e) => format!(
|
||||
"<div class=\"tlsrpt-error\">Failed to parse TLS report JSON: {}</div>",
|
||||
e
|
||||
),
|
||||
}
|
||||
} else {
|
||||
format!("<div class=\"tlsrpt-error\">Failed to convert decompressed data to UTF-8.</div>")
|
||||
}
|
||||
} else {
|
||||
format!("<div class=\"tlsrpt-error\">Failed to decompressed data.</div>")
|
||||
}
|
||||
} else {
|
||||
"".to_string()
|
||||
};
|
||||
|
||||
let final_html = if let Some(html) = html_part {
|
||||
format!("{}<hr>{} ", html, tlsrpt_summary_html)
|
||||
} else {
|
||||
tlsrpt_summary_html
|
||||
};
|
||||
part_addr.pop();
|
||||
}
|
||||
|
||||
Ok(Body::html(final_html))
|
||||
if parts.is_empty() {
|
||||
return Ok(Body::html(
|
||||
"<div class=\"report-error\">No report content found</div>".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
// Add <hr> tags between subparts for better visual separation
|
||||
let html = parts
|
||||
.iter()
|
||||
.map(|p| match p {
|
||||
Body::PlainText(PlainText { text, .. }) => {
|
||||
format!(
|
||||
r#"<p class="view-part-text-plain font-mono whitespace-pre-line">{}</p>"#,
|
||||
linkify_html(&html_escape::encode_text(text).trim_matches('\n'))
|
||||
)
|
||||
}
|
||||
Body::Html(Html { html, .. }) => html.clone(),
|
||||
Body::UnhandledContentType(UnhandledContentType { text, .. }) => {
|
||||
format!(
|
||||
r#"<p class="view-part-unhandled">{}</p>"#,
|
||||
linkify_html(&html_escape::encode_text(text).trim_matches('\n'))
|
||||
)
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("<hr>\n");
|
||||
|
||||
Ok(Body::html(html))
|
||||
}
|
||||
|
||||
pub fn extract_delivery_status(m: &ParsedMail) -> Result<Body, ServerError> {
|
||||
Ok(Body::text(m.get_body()?))
|
||||
}
|
||||
|
||||
pub fn extract_unhandled(m: &ParsedMail) -> Result<Body, ServerError> {
|
||||
|
||||
@ -11,8 +11,8 @@ version.workspace = true
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
build-info = "0.0.41"
|
||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.44", registry = "xinu" }
|
||||
build-info = "0.0.42"
|
||||
letterbox-notmuch = { path = "../notmuch", version = "0.17.45", registry = "xinu" }
|
||||
regex = "1.11.1"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
sqlx = "0.8.5"
|
||||
|
||||
@ -9,7 +9,7 @@ repository.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
build-info-build = "0.0.41"
|
||||
build-info-build = "0.0.42"
|
||||
|
||||
[dev-dependencies]
|
||||
#wasm-bindgen-test = "0.3.50"
|
||||
@ -28,12 +28,12 @@ graphql_client = "0.14.0"
|
||||
thiserror = "2.0.12"
|
||||
gloo-net = { version = "0.6.0", features = ["json", "serde_json"] }
|
||||
human_format = "1.1.0"
|
||||
build-info = "0.0.41"
|
||||
build-info = "0.0.42"
|
||||
wasm-bindgen = "=0.2.100"
|
||||
uuid = { version = "1.16.0", features = [
|
||||
"js",
|
||||
] } # direct dep to set js feature, prevents Rng issues
|
||||
letterbox-shared = { path = "../shared/", version = "0.17.44", registry = "xinu" }
|
||||
letterbox-shared = { path = "../shared/", version = "0.17.45", registry = "xinu" }
|
||||
seed_hooks = { version = "0.4.1", registry = "xinu" }
|
||||
strum_macros = "0.27.1"
|
||||
gloo-console = "0.3.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user