Compare commits

...

21 Commits

Author SHA1 Message Date
4ddbdcb46b chore(deps): lock file maintenance
Some checks failed
Continuous integration / Check (push) Successful in 1m43s
Continuous integration / Test Suite (push) Successful in 3m22s
Continuous integration / Trunk (push) Successful in 1m40s
Continuous integration / Rustfmt (push) Failing after 44s
Continuous integration / build (push) Successful in 3m39s
Continuous integration / Disallow unused dependencies (push) Failing after 2m23s
2025-08-20 00:17:43 +00:00
54dc45660a chore: Release
Some checks failed
Continuous integration / Check (push) Successful in 1m8s
Continuous integration / Test Suite (push) Successful in 1m39s
Continuous integration / Trunk (push) Successful in 55s
Continuous integration / Rustfmt (push) Failing after 39s
Continuous integration / build (push) Successful in 2m12s
Continuous integration / Disallow unused dependencies (push) Failing after 2m13s
2025-08-19 17:09:03 -07:00
3827f87111 server: address lint 2025-08-19 17:08:53 -07:00
25839328ac server: style changes for start/end datetime on calendar widget 2025-08-19 17:03:45 -07:00
b2c20cc010 chore: Release 2025-08-19 16:58:12 -07:00
7f1f61dc7d server: cargo fmt 2025-08-19 16:57:44 -07:00
6ca2459034 server: highlight today's date on the calendar widget 2025-08-19 16:57:26 -07:00
ea60cce86b server: extract calendar info and render widget on email w/o ics 2025-08-19 16:49:04 -07:00
b4113cb59a server: fmt html 2025-08-19 16:23:52 -07:00
f0493d165d server: minor style cleanup for calendar rendering 2025-08-19 16:19:56 -07:00
43d856ae7e server: move calendar widget to askama 2025-08-19 16:17:22 -07:00
5b48c5dbc3 server: move calendar rendering to askama template 2025-08-19 13:26:33 -07:00
d16c221995 server: cleanup calendar summary on mobile 2025-08-19 12:41:46 -07:00
00ce9267c1 server: improved calendar widget rendering 2025-08-19 12:04:42 -07:00
8acf541d53 server: remove excess logging 2025-08-19 12:04:29 -07:00
49e93829dd server: include a calendar widget showing the calendar event 2025-08-19 11:22:31 -07:00
a8a5089ed3 server: render calendar summary before any pre-existing text 2025-08-19 11:17:11 -07:00
cc994df4e5 server: only render text/calendar summary table on calendar invites 2025-08-19 11:09:30 -07:00
d143b2715d server: add ics testdata 2025-08-19 09:56:59 -07:00
c2428c073c server: broken parsing of google ics 2025-08-19 09:51:58 -07:00
574de65c35 server: handle application/* as an attachment 2025-08-18 12:11:31 -07:00
17 changed files with 1507 additions and 294 deletions

681
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
edition = "2021" edition = "2021"
license = "UNLICENSED" license = "UNLICENSED"
publish = ["xinu"] publish = ["xinu"]
version = "0.17.34" version = "0.17.36"
repository = "https://git.z.xinu.tv/wathiede/letterbox" repository = "https://git.z.xinu.tv/wathiede/letterbox"
[profile.dev] [profile.dev]

View File

@ -12,6 +12,8 @@ version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
chrono-tz = "0.8"
html2text = "0.6"
ammonia = "4.1.0" ammonia = "4.1.0"
anyhow = "1.0.98" anyhow = "1.0.98"
askama = { version = "0.14.0", features = ["derive"] } askama = { version = "0.14.0", features = ["derive"] }
@ -29,8 +31,10 @@ flate2 = "1.1.2"
futures = "0.3.31" futures = "0.3.31"
headers = "0.4.0" headers = "0.4.0"
html-escape = "0.2.13" html-escape = "0.2.13"
letterbox-notmuch = { path = "../notmuch", version = "0.17.34", registry = "xinu" } icalendar = "0.17.1"
letterbox-shared = { path = "../shared", version = "0.17.34", registry = "xinu" } ical = "0.10"
letterbox-notmuch = { path = "../notmuch", version = "0.17.36", registry = "xinu" }
letterbox-shared = { path = "../shared", version = "0.17.36", registry = "xinu" }
linkify = "0.10.0" linkify = "0.10.0"
lol_html = "2.3.0" lol_html = "2.3.0"
mailparse = "0.16.1" mailparse = "0.16.1"

View File

@ -119,9 +119,10 @@ async fn download_attachment(
} else { } else {
format!("id:{}", id) format!("id:{}", id)
}; };
info!("download attachment {mid} {idx}"); info!("download attachment message id '{mid}' idx '{idx}'");
let idx: Vec<_> = idx let idx: Vec<_> = idx
.split('.') .split('.')
.filter(|s| !s.is_empty())
.map(|s| s.parse().expect("not a usize")) .map(|s| s.parse().expect("not a usize"))
.collect(); .collect();
let attachment = attachment_bytes(&nm, &mid, &idx)?; let attachment = attachment_bytes(&nm, &mid, &idx)?;

View File

@ -1,7 +1,358 @@
// --- TESTS ---
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn google_calendar_email_renders_ical_summary() {
use mailparse::parse_mail;
let raw_email = include_str!("../testdata/google-calendar-example.eml");
let parsed = parse_mail(raw_email.as_bytes()).expect("parse_mail");
let mut part_addr = vec![];
let body = extract_body(&parsed, &mut part_addr).expect("extract_body");
let meta = extract_calendar_metadata_from_mail(&parsed, &body);
// Assert detection as Google Calendar
assert!(meta.is_google_calendar_event);
// Assert metadata extraction
assert_eq!(meta.summary, Some("Tamara and Scout in Alaska".to_string()));
assert_eq!(meta.organizer, Some("tconvertino@gmail.com".to_string()));
assert_eq!(meta.start_date, Some("20250624".to_string()));
assert_eq!(meta.end_date, Some("20250701".to_string()));
// Debug: print the rendered HTML for inspection
if let Some(ref html) = meta.body_html {
println!("Rendered HTML: {}", html);
} else {
println!("No body_html rendered");
}
// Assert ical summary is rendered and prepended (look for 'ical-flex' class)
assert!(meta
.body_html
.as_ref()
.map(|h| h.contains("ical-flex"))
.unwrap_or(false));
}
}
#[derive(Debug, PartialEq)]
pub struct ExtractedCalendarMetadata {
pub is_google_calendar_event: bool,
pub summary: Option<String>,
pub organizer: Option<String>,
pub start_date: Option<String>,
pub end_date: Option<String>,
pub body_html: Option<String>,
}
/// Helper to extract Google Calendar event metadata from a ParsedMail (for tests and features)
pub fn extract_calendar_metadata_from_mail(
m: &ParsedMail,
body: &Body,
) -> ExtractedCalendarMetadata {
// Detect Google Calendar by sender or headers
let mut is_google = false;
let mut summary = None;
let mut organizer = None;
let mut start_date = None;
let mut end_date = None;
let mut body_html = None;
// Check sender
if let Some(from) = m.headers.get_first_value("Sender") {
if from.contains("calendar-notification@google.com") {
is_google = true;
}
}
// Check for Google Calendar subject
if let Some(subject) = m.headers.get_first_value("Subject") {
if subject.contains("New event:") || subject.contains("Google Calendar") {
is_google = true;
}
}
// Try to extract from text/calendar part if present
fn find_ical<'a>(m: &'a ParsedMail) -> Option<String> {
if m.ctype.mimetype == TEXT_CALENDAR {
m.get_body().ok()
} else {
for sp in &m.subparts {
if let Some(b) = find_ical(sp) {
return Some(b);
}
}
None
}
}
let ical_opt = find_ical(m);
if let Some(ical) = ical_opt {
// Use existing render_ical_summary to extract fields
if let Ok(rendered) = render_ical_summary(&ical) {
// Try to extract summary, organizer, start/end from the ical
// (This is a hack: parse the ical again for fields)
use ical::IcalParser;
let mut parser = IcalParser::new(ical.as_bytes());
if let Some(Ok(calendar)) = parser.next() {
for event in calendar.events {
for prop in &event.properties {
match prop.name.as_str() {
"SUMMARY" => summary = prop.value.clone(),
"ORGANIZER" => organizer = prop.value.clone(),
"DTSTART" => {
if let Some(dt) = &prop.value {
if dt.len() >= 8 {
start_date = Some(dt[0..8].to_string());
}
}
}
"DTEND" => {
if let Some(dt) = &prop.value {
if dt.len() >= 8 {
end_date = Some(dt[0..8].to_string());
}
}
}
_ => {}
}
}
}
}
body_html = Some(rendered);
}
} else {
// Fallback: try to extract summary and organizer from headers if this is a Google Calendar event
if is_google {
if let Some(subject) = m.headers.get_first_value("Subject") {
// Try to extract event summary from subject, e.g. "New event: Tamara and Scout in Alaska @ ..."
let summary_guess = subject
.splitn(2, ':')
.nth(1)
.and_then(|s| s.split('@').next())
.map(|s| s.trim().to_string());
if let Some(s) = summary_guess {
summary = Some(s);
}
// Try to extract start/end dates from subject, e.g. "@ Tue Jun 24 - Mon Jun 30, 2025"
if let Some(at_idx) = subject.find('@') {
let after_at = &subject[at_idx + 1..];
// Look for a date range like "Tue Jun 24 - Mon Jun 30, 2025"
let date_re = regex::Regex::new(
r"(\w{3}) (\w{3}) (\d{1,2}) - (\w{3}) (\w{3}) (\d{1,2}), (\d{4})",
)
.ok();
if let Some(re) = &date_re {
if let Some(caps) = re.captures(after_at) {
// e.g. Tue Jun 24 - Mon Jun 30, 2025
let start_month = &caps[2];
let start_day = &caps[3];
let end_month = &caps[5];
let end_day = &caps[6];
let year = &caps[7];
// Try to parse months as numbers
let month_map = [
("Jan", "01"),
("Feb", "02"),
("Mar", "03"),
("Apr", "04"),
("May", "05"),
("Jun", "06"),
("Jul", "07"),
("Aug", "08"),
("Sep", "09"),
("Oct", "10"),
("Nov", "11"),
("Dec", "12"),
];
let start_month_num = month_map
.iter()
.find(|(m, _)| *m == start_month)
.map(|(_, n)| *n)
.unwrap_or("01");
let end_month_num = month_map
.iter()
.find(|(m, _)| *m == end_month)
.map(|(_, n)| *n)
.unwrap_or("01");
let start_date_str = format!(
"{}{}{}",
year,
start_month_num,
format!("{:0>2}", start_day)
);
let end_date_str =
format!("{}{}{}", year, end_month_num, format!("{:0>2}", end_day));
// Increment end date by one day to match iCalendar exclusive end date
let end_date_exclusive =
chrono::NaiveDate::parse_from_str(&end_date_str, "%Y%m%d")
.ok()
.and_then(|d| d.succ_opt())
.map(|d| d.format("%Y%m%d").to_string())
.unwrap_or(end_date_str);
start_date = Some(start_date_str);
end_date = Some(end_date_exclusive);
}
}
}
}
// Try to extract organizer from From header
if organizer.is_none() {
if let Some(from) = m.headers.get_first_value("From") {
// Try to extract email address from From header
let email = from
.split('<')
.nth(1)
.and_then(|s| s.split('>').next())
.map(|s| s.trim().to_string())
.or_else(|| Some(from.trim().to_string()));
organizer = email;
}
}
// Render the ical-summary template using the extracted metadata if we have enough info
if summary.is_some() && start_date.is_some() && end_date.is_some() {
use chrono::NaiveDate;
let summary_val = summary.as_deref().unwrap_or("");
let organizer_val = organizer.as_deref().unwrap_or("");
let allday = start_date.as_ref().map(|s| s.len() == 8).unwrap_or(false)
&& end_date.as_ref().map(|s| s.len() == 8).unwrap_or(false);
let local_fmt_start = start_date
.as_ref()
.and_then(|d| NaiveDate::parse_from_str(d, "%Y%m%d").ok())
.map(|d| {
if allday {
d.format("%a %b %e, %Y").to_string()
} else {
d.format("%-I:%M %p %a %b %e, %Y").to_string()
}
})
.unwrap_or_default();
let local_fmt_end = end_date
.as_ref()
.and_then(|d| NaiveDate::parse_from_str(d, "%Y%m%d").ok())
.map(|d| {
if allday {
d.format("%a %b %e, %Y").to_string()
} else {
d.format("%-I:%M %p %a %b %e, %Y").to_string()
}
})
.unwrap_or_default();
let mut event_days = vec![];
if let (Some(start), Some(end)) = (start_date.as_ref(), end_date.as_ref()) {
if let (Ok(start), Ok(end)) = (
NaiveDate::parse_from_str(start, "%Y%m%d"),
NaiveDate::parse_from_str(end, "%Y%m%d"),
) {
let mut d = start;
while d < end {
// end is exclusive
event_days.push(d);
d = d.succ_opt().unwrap();
}
}
}
// Compute calendar grid for template rendering
let (all_days, caption) = if !event_days.is_empty() {
let first_event = event_days.first().unwrap();
let last_event = event_days.last().unwrap();
let first_of_month =
NaiveDate::from_ymd_opt(first_event.year(), first_event.month(), 1)
.unwrap();
let last_of_month = {
let next_month = if last_event.month() == 12 {
NaiveDate::from_ymd_opt(last_event.year() + 1, 1, 1).unwrap()
} else {
NaiveDate::from_ymd_opt(last_event.year(), last_event.month() + 1, 1)
.unwrap()
};
next_month.pred_opt().unwrap()
};
let mut cal_start = first_of_month;
while cal_start.weekday() != chrono::Weekday::Sun {
cal_start = cal_start.pred_opt().unwrap();
}
let mut cal_end = last_of_month;
while cal_end.weekday() != chrono::Weekday::Sat {
cal_end = cal_end.succ_opt().unwrap();
}
let mut all_days = vec![];
let mut d = cal_start;
while d <= cal_end {
all_days.push(d);
d = d.succ_opt().unwrap();
}
let start_month = first_event.format("%B %Y");
let end_month = last_event.format("%B %Y");
let caption = if start_month.to_string() == end_month.to_string() {
start_month.to_string()
} else {
format!("{} {}", start_month, end_month)
};
(all_days, caption)
} else {
(vec![], String::new())
};
let description_paragraphs: Vec<String> = Vec::new();
let template = IcalSummaryTemplate {
summary: summary_val,
local_fmt_start: &local_fmt_start,
local_fmt_end: &local_fmt_end,
organizer: organizer_val,
organizer_cn: "",
all_days,
event_days: event_days.clone(),
caption,
description_paragraphs: &description_paragraphs,
today: Some(chrono::Local::now().date_naive()),
};
if let Ok(rendered) = template.render() {
body_html = Some(rendered);
}
}
}
}
// Fallback: try to extract from HTML body if present
if body_html.is_none() {
if let Body::Html(h) = body {
body_html = Some(h.html.clone());
}
}
ExtractedCalendarMetadata {
is_google_calendar_event: is_google,
summary,
organizer,
start_date,
end_date,
body_html,
}
}
// Inline Askama filters module for template use
mod filters {
// Usage: {{ items|batch(7) }}
pub fn batch<T: Clone>(
items: &[T],
_: &dyn ::askama::Values,
size: usize,
) -> askama::Result<Vec<Vec<T>>> {
if size == 0 {
return Ok(vec![]);
}
let mut out = Vec::new();
let mut chunk = Vec::with_capacity(size);
for item in items {
chunk.push(item.clone());
if chunk.len() == size {
out.push(chunk);
chunk = Vec::with_capacity(size);
}
}
if !chunk.is_empty() {
out.push(chunk);
}
Ok(out)
}
}
use std::io::{Cursor, Read}; use std::io::{Cursor, Read};
use askama::Template; use askama::Template;
use chrono::{TimeZone, Utc}; use chrono::{Datelike, Local, LocalResult, NaiveDate, TimeZone, Utc};
use chrono_tz::Tz;
use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail}; use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail};
use quick_xml::de::from_str as xml_from_str; use quick_xml::de::from_str as xml_from_str;
use tracing::{error, info, warn}; use tracing::{error, info, warn};
@ -24,6 +375,7 @@ const MULTIPART_ALTERNATIVE: &'static str = "multipart/alternative";
const MULTIPART_MIXED: &'static str = "multipart/mixed"; const MULTIPART_MIXED: &'static str = "multipart/mixed";
const MULTIPART_RELATED: &'static str = "multipart/related"; const MULTIPART_RELATED: &'static str = "multipart/related";
const MULTIPART_REPORT: &'static str = "multipart/report"; const MULTIPART_REPORT: &'static str = "multipart/report";
const TEXT_CALENDAR: &'static str = "text/calendar";
const TEXT_HTML: &'static str = "text/html"; const TEXT_HTML: &'static str = "text/html";
const TEXT_PLAIN: &'static str = "text/plain"; const TEXT_PLAIN: &'static str = "text/plain";
@ -87,6 +439,7 @@ pub fn extract_body(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Body,
// APPLICATION_ZIP and APPLICATION_GZIP are handled in the thread function // APPLICATION_ZIP and APPLICATION_GZIP are handled in the thread function
APPLICATION_ZIP => extract_unhandled(m), APPLICATION_ZIP => extract_unhandled(m),
APPLICATION_GZIP => extract_unhandled(m), APPLICATION_GZIP => extract_unhandled(m),
mt if mt.starts_with("application/") => Ok(Body::text("".to_string())),
_ => extract_unhandled(m), _ => extract_unhandled(m),
}; };
if let Err(err) = ret { if let Err(err) = ret {
@ -307,6 +660,7 @@ pub fn extract_alternative(
MULTIPART_ALTERNATIVE, MULTIPART_ALTERNATIVE,
MULTIPART_MIXED, MULTIPART_MIXED,
MULTIPART_RELATED, MULTIPART_RELATED,
TEXT_CALENDAR,
TEXT_HTML, TEXT_HTML,
TEXT_PLAIN, TEXT_PLAIN,
]; ];
@ -325,18 +679,53 @@ pub fn extract_alternative(
return extract_related(sp, part_addr); return extract_related(sp, part_addr);
} }
} }
let mut ical_summary: Option<String> = None;
// Try to find a text/calendar part as before
for sp in &m.subparts {
if sp.ctype.mimetype.as_str() == TEXT_CALENDAR {
let body = sp.get_body()?;
let summary = render_ical_summary(&body)?;
ical_summary = Some(summary);
break;
}
}
// If not found, try to detect Google Calendar event and render summary from metadata
if ical_summary.is_none() {
let meta = extract_calendar_metadata_from_mail(m, &Body::text(String::new()));
if meta.is_google_calendar_event {
if let Some(rendered) = meta.body_html {
ical_summary = Some(rendered);
}
}
}
for sp in &m.subparts { for sp in &m.subparts {
if sp.ctype.mimetype.as_str() == TEXT_HTML { if sp.ctype.mimetype.as_str() == TEXT_HTML {
let body = sp.get_body()?; let body = sp.get_body()?;
return Ok(Body::html(body)); if let Some(ref summary) = ical_summary {
// Prepend summary to HTML body
let combined = format!("{}<hr>{}", summary, body);
return Ok(Body::html(combined));
} else {
return Ok(Body::html(body));
}
} }
} }
for sp in &m.subparts { for sp in &m.subparts {
if sp.ctype.mimetype.as_str() == TEXT_PLAIN { if sp.ctype.mimetype.as_str() == TEXT_PLAIN {
let body = sp.get_body()?; let body = sp.get_body()?;
return Ok(Body::text(body)); if let Some(ref summary) = ical_summary {
// Prepend summary to plain text body (strip HTML tags)
let summary_text = html2text::from_read(summary.as_bytes(), 80);
let combined = format!("{}\n\n{}", summary_text.trim(), body);
return Ok(Body::text(combined));
} else {
return Ok(Body::text(body));
}
} }
} }
if let Some(summary) = ical_summary {
return Ok(Body::html(summary));
}
Err(ServerError::StringError(format!( Err(ServerError::StringError(format!(
"extract_alternative failed to find suitable subpart, searched: {:?}", "extract_alternative failed to find suitable subpart, searched: {:?}",
handled_types handled_types
@ -362,7 +751,7 @@ pub fn extract_mixed(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Body
.subparts .subparts
.iter() .iter()
.map(|sp| sp.ctype.mimetype.as_str()) .map(|sp| sp.ctype.mimetype.as_str())
.filter(|mt| !handled_types.contains(mt)) .filter(|mt| !handled_types.contains(mt) && !mt.starts_with("application/"))
.collect(); .collect();
unhandled_types.sort(); unhandled_types.sort();
if !unhandled_types.is_empty() { if !unhandled_types.is_empty() {
@ -413,9 +802,9 @@ pub fn extract_mixed(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Body
// For DMARC, it's always XML. // For DMARC, it's always XML.
// Pretty print JSON (if it were TLS) // Pretty print JSON (if it were TLS)
if let Ok(parsed_json) = serde_json::from_str::<serde_json::Value>(&xml) { if let Ok(parsed_json) = serde_json::from_str::<serde_json::Value>(&xml) {
serde_json::to_string_pretty(&parsed_json).unwrap_or(xml) serde_json::to_string_pretty(&parsed_json).unwrap_or(xml.to_string())
} else { } else {
xml xml.to_string()
} }
} else { } else {
// DMARC reports are XML // DMARC reports are XML
@ -424,7 +813,7 @@ pub fn extract_mixed(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Body
Ok(pretty_xml) => pretty_xml, Ok(pretty_xml) => pretty_xml,
Err(e) => { Err(e) => {
error!("Failed to pretty print XML: {:?}", e); error!("Failed to pretty print XML: {:?}", e);
xml xml.to_string()
} }
} }
}; };
@ -434,7 +823,11 @@ pub fn extract_mixed(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Body
))); )));
} }
} }
mt => parts.push(unhandled_html(MULTIPART_MIXED, mt)), mt => {
if !mt.starts_with("application/") {
parts.push(unhandled_html(MULTIPART_MIXED, mt))
}
}
} }
part_addr.pop(); part_addr.pop();
} }
@ -500,7 +893,7 @@ pub fn extract_related(m: &ParsedMail, part_addr: &mut Vec<String>) -> Result<Bo
.subparts .subparts
.iter() .iter()
.map(|sp| sp.ctype.mimetype.as_str()) .map(|sp| sp.ctype.mimetype.as_str())
.filter(|mt| !handled_types.contains(mt)) .filter(|mt| !handled_types.contains(mt) && !mt.starts_with("application/"))
.collect(); .collect();
unhandled_types.sort(); unhandled_types.sort();
if !unhandled_types.is_empty() { if !unhandled_types.is_empty() {
@ -580,6 +973,13 @@ pub fn walk_attachments_inner<T, F: Fn(&ParsedMail, &[usize]) -> Option<T> + Cop
// get the bytes for serving attachments of HTTP // get the bytes for serving attachments of HTTP
pub fn extract_attachments(m: &ParsedMail, id: &str) -> Result<Vec<Attachment>, ServerError> { pub fn extract_attachments(m: &ParsedMail, id: &str) -> Result<Vec<Attachment>, ServerError> {
let mut attachments = Vec::new(); let mut attachments = Vec::new();
if m.ctype.mimetype.starts_with("application/") {
if let Some(attachment) = extract_attachment(m, id, &[]) {
attachments.push(attachment);
}
}
for (idx, sp) in m.subparts.iter().enumerate() { for (idx, sp) in m.subparts.iter().enumerate() {
if let Some(attachment) = extract_attachment(sp, id, &[idx]) { if let Some(attachment) = extract_attachment(sp, id, &[idx]) {
// Filter out inline attachements, they're flattened into the body of the message. // Filter out inline attachements, they're flattened into the body of the message.
@ -602,12 +1002,30 @@ pub fn extract_attachment(m: &ParsedMail, id: &str, idx: &[usize]) -> Option<Att
pct.map(|pct| pct.params.get("name").map(|f| f.clone())), pct.map(|pct| pct.params.get("name").map(|f| f.clone())),
) { ) {
// Use filename from Content-Disposition // Use filename from Content-Disposition
(Some(filename), _) => filename, (Some(filename), _) => Some(filename),
// Use filename from Content-Type // Use filename from Content-Type
(_, Some(Some(name))) => name, (_, Some(Some(name))) => Some(name),
// No known filename, assume it's not an attachment // No known filename
_ => return None, _ => None,
}; };
let filename = if let Some(fname) = filename {
fname
} else {
if m.ctype.mimetype.starts_with("application/") {
// Generate a default filename
format!(
"attachment-{}",
idx.iter()
.map(|i| i.to_string())
.collect::<Vec<_>>()
.join(".")
)
} else {
return None;
}
};
info!("filename {}", filename); info!("filename {}", filename);
// TODO: grab this from somewhere // TODO: grab this from somewhere
@ -1033,6 +1451,21 @@ pub struct TlsReportTemplate<'a> {
pub report: &'a FormattedTlsRpt, pub report: &'a FormattedTlsRpt,
} }
#[derive(Template)]
#[template(path = "ical_summary.html")]
pub struct IcalSummaryTemplate<'a> {
pub summary: &'a str,
pub local_fmt_start: &'a str,
pub local_fmt_end: &'a str,
pub organizer: &'a str,
pub organizer_cn: &'a str,
pub all_days: Vec<chrono::NaiveDate>,
pub event_days: Vec<chrono::NaiveDate>,
pub caption: String,
pub description_paragraphs: &'a [String],
pub today: Option<chrono::NaiveDate>,
}
// Add this helper function to parse the DMARC XML and summarize it. // Add this helper function to parse the DMARC XML and summarize it.
pub fn parse_dmarc_report(xml: &str) -> Result<String, ServerError> { pub fn parse_dmarc_report(xml: &str) -> Result<String, ServerError> {
let feedback: Feedback = xml_from_str(xml) let feedback: Feedback = xml_from_str(xml)
@ -1233,24 +1666,196 @@ pub fn pretty_print_xml_with_trimming(xml_input: &str) -> Result<String, ServerE
Ok(String::from_utf8(result)?) Ok(String::from_utf8(result)?)
} }
#[cfg(test)] use ical::IcalParser;
mod tests {
use std::fs;
use super::*; pub fn render_ical_summary(ical_data: &str) -> Result<String, ServerError> {
let mut summary_parts = Vec::new();
let mut parser = IcalParser::new(ical_data.as_bytes());
while let Some(Ok(calendar)) = parser.next() {
for event in calendar.events {
let mut summary = None;
let mut description = None;
let mut dtstart = None;
let mut dtend = None;
let mut organizer = None;
let mut organizer_cn = None;
let mut tzid: Option<String> = None;
for prop in &event.properties {
match prop.name.as_str() {
"SUMMARY" => summary = prop.value.as_deref(),
"DESCRIPTION" => description = prop.value.as_deref(),
"DTSTART" => {
dtstart = prop.value.as_deref();
if let Some(params) = &prop.params {
if let Some((_, values)) = params.iter().find(|(k, _)| k == "TZID") {
if let Some(val) = values.get(0) {
tzid = Some(val.clone());
}
}
}
}
"DTEND" => dtend = prop.value.as_deref(),
"ORGANIZER" => {
organizer = prop.value.as_deref();
if let Some(params) = &prop.params {
if let Some((_, values)) = params.iter().find(|(k, _)| k == "CN") {
if let Some(cn) = values.get(0) {
organizer_cn = Some(cn.as_str());
}
}
}
}
_ => {}
}
}
#[test] // Parse start/end as chrono DateTime
fn test_parse_dmarc_report() { let (local_fmt_start, local_fmt_end, event_days) = if let Some(dtstart) = dtstart {
let xml = fs::read_to_string("testdata/dmarc-example.xml").unwrap(); let tz: Tz = tzid
let html = parse_dmarc_report(&xml).unwrap(); .as_deref()
assert!(html.contains("hotmail.com")); .unwrap_or("UTC")
assert!(html.contains("msn.com")); .parse()
.unwrap_or(chrono_tz::UTC);
let fallback = chrono::DateTime::<chrono::Utc>::from_timestamp(0, 0)
.map(|dt| dt.with_timezone(&tz))
.unwrap_or_else(|| {
tz.with_ymd_and_hms(1970, 1, 1, 0, 0, 0)
.single()
.unwrap_or_else(|| tz.timestamp_opt(0, 0).single().unwrap())
});
let start = parse_ical_datetime_tz(dtstart, tz).unwrap_or(fallback);
let end = dtend
.and_then(|d| parse_ical_datetime_tz(d, tz))
.unwrap_or(start);
let local_start = start.with_timezone(&Local);
let local_end = end.with_timezone(&Local);
let allday = dtstart.len() == 8 && (dtend.map(|s| s.len() == 8).unwrap_or(false));
let fmt_start = if allday {
local_start.format("%a %b %e, %Y").to_string()
} else {
local_start.format("%-I:%M %p %a %b %e, %Y").to_string()
};
let fmt_end = if allday {
local_end.format("%a %b %e, %Y").to_string()
} else {
local_end.format("%-I:%M %p %a %b %e, %Y").to_string()
};
let mut days = vec![];
let d = start.date_naive();
let mut end_d = end.date_naive();
// Check for all-day event (DATE, not DATE-TIME)
let allday = dtstart.len() == 8 && (dtend.map(|s| s.len() == 8).unwrap_or(false));
if allday {
// DTEND is exclusive for all-day events
if end_d > d {
end_d = end_d.pred_opt().unwrap();
}
}
// Only include actual event days
let mut day_iter = d;
while day_iter <= end_d {
days.push(day_iter);
day_iter = day_iter.succ_opt().unwrap();
}
(fmt_start, fmt_end, days)
} else {
(String::new(), String::new(), vec![])
};
// Compute calendar grid for template rendering
let (all_days, caption) = if !event_days.is_empty() {
let first_event = event_days.first().unwrap();
let last_event = event_days.last().unwrap();
let first_of_month =
NaiveDate::from_ymd_opt(first_event.year(), first_event.month(), 1).unwrap();
let last_of_month = {
let next_month = if last_event.month() == 12 {
NaiveDate::from_ymd_opt(last_event.year() + 1, 1, 1).unwrap()
} else {
NaiveDate::from_ymd_opt(last_event.year(), last_event.month() + 1, 1)
.unwrap()
};
next_month.pred_opt().unwrap()
};
let mut cal_start = first_of_month;
while cal_start.weekday() != chrono::Weekday::Sun {
cal_start = cal_start.pred_opt().unwrap();
}
let mut cal_end = last_of_month;
while cal_end.weekday() != chrono::Weekday::Sat {
cal_end = cal_end.succ_opt().unwrap();
}
let mut all_days = vec![];
let mut d = cal_start;
while d <= cal_end {
all_days.push(d);
d = d.succ_opt().unwrap();
}
let start_month = first_event.format("%B %Y");
let end_month = last_event.format("%B %Y");
let caption = if start_month.to_string() == end_month.to_string() {
start_month.to_string()
} else {
format!("{} {}", start_month, end_month)
};
(all_days, caption)
} else {
(vec![], String::new())
};
// Description paragraphs
let description_paragraphs: Vec<String> = if let Some(desc) = description {
let desc = desc.replace("\\n", "\n");
desc.lines()
.map(|line| line.trim().to_string())
.filter(|line| !line.is_empty())
.collect::<Vec<_>>()
} else {
Vec::new()
};
let summary_val = summary.unwrap_or("");
let organizer_val = organizer.unwrap_or("");
let organizer_cn_val = organizer_cn.unwrap_or("");
let local_fmt_start_val = &local_fmt_start;
let local_fmt_end_val = &local_fmt_end;
let description_paragraphs_val = &description_paragraphs;
let template = IcalSummaryTemplate {
summary: summary_val,
local_fmt_start: local_fmt_start_val,
local_fmt_end: local_fmt_end_val,
organizer: organizer_val,
organizer_cn: organizer_cn_val,
all_days,
event_days: event_days.clone(),
caption,
description_paragraphs: description_paragraphs_val,
today: Some(chrono::Local::now().date_naive()),
};
summary_parts.push(template.render()?);
}
} }
Ok(summary_parts.join("<hr>"))
}
#[test]
fn test_parse_dmarc_report_no_envelope_to() { fn parse_ical_datetime_tz(dt: &str, tz: Tz) -> Option<chrono::DateTime<Tz>> {
let xml = fs::read_to_string("testdata/dmarc-example-no-envelope-to.xml").unwrap(); let dt = dt.split(':').last().unwrap_or(dt);
let html = parse_dmarc_report(&xml).unwrap(); if let Ok(ndt) = chrono::NaiveDateTime::parse_from_str(dt, "%Y%m%dT%H%M%SZ") {
assert!(!html.contains("Envelope To")); Some(tz.from_utc_datetime(&ndt))
} else if let Ok(ndt) = chrono::NaiveDateTime::parse_from_str(dt, "%Y%m%dT%H%M%S") {
match tz.from_local_datetime(&ndt) {
LocalResult::Single(dt) => Some(dt),
_ => None,
}
} else if let Ok(nd) = chrono::NaiveDate::parse_from_str(dt, "%Y%m%d") {
// All-day event: treat as midnight in local time
let ndt = nd.and_hms_opt(0, 0, 0).unwrap();
match tz.from_local_datetime(&ndt) {
LocalResult::Single(dt) => Some(dt),
_ => None,
}
} else {
None
} }
} }

View File

@ -242,7 +242,9 @@ impl Body {
match self { match self {
Body::Html(h) => Some(h.html.clone()), Body::Html(h) => Some(h.html.clone()),
Body::PlainText(p) => Some(format!("<pre>{}</pre>", html_escape::encode_text(&p.text))), Body::PlainText(p) => Some(format!("<pre>{}</pre>", html_escape::encode_text(&p.text))),
Body::UnhandledContentType(u) => Some(format!("<pre>{}</pre>", html_escape::encode_text(&u.text))), Body::UnhandledContentType(u) => {
Some(format!("<pre>{}</pre>", html_escape::encode_text(&u.text)))
}
} }
} }

View File

@ -376,11 +376,6 @@ pub async fn thread(
current_html.push_str(&html_summary); current_html.push_str(&html_summary);
} }
error!(
"mimetype {} raw_report_content.is_some() {}",
m.ctype.mimetype.as_str(),
raw_report_content.is_some()
);
if let Some(raw_content) = raw_report_content { if let Some(raw_content) = raw_report_content {
let pretty_printed_content = if m.ctype.mimetype.as_str() == MULTIPART_REPORT { let pretty_printed_content = if m.ctype.mimetype.as_str() == MULTIPART_REPORT {
// Pretty print JSON // Pretty print JSON
@ -479,6 +474,12 @@ pub fn attachment_bytes(nm: &Notmuch, id: &str, idx: &[usize]) -> Result<Attachm
let file = File::open(&path)?; let file = File::open(&path)?;
let mmap = unsafe { MmapOptions::new().map(&file)? }; let mmap = unsafe { MmapOptions::new().map(&file)? };
let m = parse_mail(&mmap)?; let m = parse_mail(&mmap)?;
if idx.is_empty() {
let Some(attachment) = extract_attachment(&m, id, &[]) else {
return Err(ServerError::PartNotFound);
};
return Ok(attachment);
}
if let Some(attachment) = walk_attachments(&m, |sp, cur_idx| { if let Some(attachment) = walk_attachments(&m, |sp, cur_idx| {
if cur_idx == idx { if cur_idx == idx {
let attachment = extract_attachment(&sp, id, idx).unwrap_or(Attachment { let attachment = extract_attachment(&sp, id, idx).unwrap_or(Attachment {
@ -811,6 +812,6 @@ mod tests {
#[test] #[test]
fn test_parse_tls_report_v1() { fn test_parse_tls_report_v1() {
let report: TlsRpt = serde_json::from_str(REPORT_V1).unwrap(); let _report: TlsRpt = serde_json::from_str(REPORT_V1).unwrap();
} }
} }

View File

@ -1,7 +0,0 @@
use askama::Template;
#[derive(Template)]
#[template(path = "dmarc_report.html")]
pub struct DmarcReportTemplate<'a> {
pub feedback: &'a crate::nm::Feedback,
}

View File

@ -0,0 +1,108 @@
<style>
.ical-flex {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: stretch;
gap: 0.5em;
max-width: 700px;
width: 100%;
}
.ical-flex .summary-block {
flex: 1 1 0%;
}
.ical-flex .calendar-block {
flex: none;
margin-left: auto;
}
@media (max-width: 599px) {
.ical-flex {
flex-direction: column;
}
.ical-flex>div.summary-block {
margin-bottom: 0.5em;
margin-left: 0;
}
.ical-flex>div.calendar-block {
margin-left: 0;
}
}
</style>
<div class="ical-flex">
<div class="summary-block"
style="background:#f7f7f7; border-radius:8px; box-shadow:0 2px 8px #bbb; padding:16px 18px; margin:0 0 8px 0; min-width:220px; max-width:700px; font-size:15px; color:#222;">
<div
style="display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 0.5em; width: 100%;">
<div style="flex: 1 1 220px; min-width: 180px;">
<div style="font-size:17px; font-weight:bold; margin-bottom:8px; color:#333;"><b>Summary:</b> {{ summary
}}</div>
<div style="margin-bottom:4px;"><b>Start:</b> {{ local_fmt_start }}</div>
<div style="margin-bottom:4px;"><b>End:</b> {{ local_fmt_end }}</div>
{% if !organizer_cn.is_empty() %}
<div style="margin-bottom:4px;"><b>Organizer:</b> {{ organizer_cn }}</div>
{% elif !organizer.is_empty() %}
<div style="margin-bottom:4px;"><b>Organizer:</b> {{ organizer }}</div>
{% endif %}
</div>
{% if all_days.len() > 0 %}
<div class="calendar-block" style="flex: none; margin-left: auto; min-width: 180px;">
<table class="ical-month"
style="border-collapse:collapse; min-width:220px; background:#fff; box-shadow:0 2px 8px #bbb; font-size:14px; margin:0;">
<caption
style="caption-side:top; text-align:center; font-weight:bold; font-size:16px; padding-bottom:8px 0;">
{{ caption }}</caption>
<thead>
<tr>
{% for wd in ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] %}
<th
style="padding:4px 6px; border-bottom:1px solid #ccc; color:#666; font-weight:600; background:#f7f7f7">
{{ wd }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for week in all_days|batch(7) %}
<tr>
{% for day in week %}
{% if event_days.contains(day) && today.is_some() && today.unwrap() == day %}
<td
style="background:#ffd700; color:#222; font-weight:bold; border:2px solid #2196f3; border-radius:4px; text-align:center; box-shadow:0 0 0 2px #2196f3;">
{{ day.day() }}
</td>
{% elif event_days.contains(day) %}
<td
style="background:#ffd700; color:#222; font-weight:bold; border:1px solid #aaa; border-radius:4px; text-align:center;">
{{ day.day() }}
</td>
{% elif today.is_some() && today.unwrap() == day %}
<td
style="border:2px solid #2196f3; border-radius:4px; text-align:center; background:#e3f2fd; color:#222; box-shadow:0 0 0 2px #2196f3;">
{{ day.day() }}
</td>
{% else %}
<td style="border:1px solid #eee; text-align:center;background:#f7f7f7;color:#bbb;">
{{ day.day() }}
</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
</div>
</div>
{% if !description_paragraphs.is_empty() %}
<div style="max-width:700px; width:100%;">
{% for p in description_paragraphs %}
<p style="margin: 0 0 8px 0; color:#444;">{{ p }}</p>
{% endfor %}
</div>
{% endif %}

View File

@ -0,0 +1,169 @@
Return-Path: <couchmoney+caf_=gmail=xinu.tv@gmail.com>
Delivered-To: bill@xinu.tv
Received: from phx.xinu.tv [74.207.253.222]
by nixos-01.h.xinu.tv with IMAP (fetchmail-6.4.39)
for <wathiede@localhost> (single-drop); Mon, 02 Jun 2025 07:06:34 -0700 (PDT)
Received: from phx.xinu.tv
by phx.xinu.tv with LMTP
id qDo+FuqvPWh51xIAJR8clQ
(envelope-from <couchmoney+caf_=gmail=xinu.tv@gmail.com>)
for <bill@xinu.tv>; Mon, 02 Jun 2025 07:06:34 -0700
X-Original-To: gmail@xinu.tv
Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::130; helo=mail-lf1-x130.google.com; envelope-from=couchmoney+caf_=gmail=xinu.tv@gmail.com; receiver=xinu.tv
Authentication-Results: phx.xinu.tv;
dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=zT2yUtVH;
dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=nmJW8N67
Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130])
by phx.xinu.tv (Postfix) with ESMTPS id 912AC80034
for <gmail@xinu.tv>; Mon, 02 Jun 2025 07:06:32 -0700 (PDT)
Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-54e7967cf67so5267078e87.0
for <gmail@xinu.tv>; Mon, 02 Jun 2025 07:06:32 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1748873190; cv=pass;
d=google.com; s=arc-20240605;
b=W3s0wT+CV1W21AldY9lfxPlKRbc7XMoorEnilNq5iGjlw18vDM6eFPb+btqaGAPOPe
CMyGeinsFPuql+S7u6HgjZcf9ZFH71sKoFoQytm30hAXB76GO06qi1jRW6o0miuGt/j/
bb8qWAiAsGr34mHIbE5fBdkNOGcqW85oI78GolLqpROgn/42boEYxiGAQjybPtO4L84J
wP2RBkHiQQGXUjL6b02tozCji1w2XdfYqtW8RteUs1pqYdXl4GUilMLt5C0d2bhSGksS
3tMTFjuycbaj+F6QFCkQfEsHx/I7GjuD4mToLcYpzrNnmZZUidAoKuh+uin0cEVvnQ1j
V8aA==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605;
h=to:from:subject:date:message-id:auto-submitted:sender:reply-to
:mime-version:dkim-signature:dkim-signature:delivered-to;
bh=dgRmOj3aABlB3SNw+xxlI8L9ugJFZ1WMJrtLw/W8tnA=;
fh=5zy5Gi9ngAea7dC9ZKKPh/BZlFmotJq74g9KHrEIwaE=;
b=QTAjqit0gYnuGa1lbO9RUXOVpyutliNo+tG6irWFsjGhnvMkis2KdLb6saYPnLCG7F
rSRXvw0HwuaJfXAV3XvIT0pxTg3PXYnc8kt/F8OtG+LiakJbMV1soj8OJ+5lZPKFmvna
i2T5mJjEknZsc9qWYmaAEVqIg71jhPH5CjJyehNhsIJ1/O9CH4VF8L0yv9KUMAA4tzog
LfI+SpOE2z/wYuMDxi2Ld3FgaVCQgkMM2Tlys8P0DjCaewWeaZFmZKIEEZUbKWbrivTa
RSO+Us+9yrt8hDdJuvtf9eXsGvuZtdj/2APRts/0cd7SFAQqRd0DnhGIHoXR74YVHaqi
U7IQ==;
darn=xinu.tv
ARC-Authentication-Results: i=2; mx.google.com;
dkim=pass header.i=@google.com header.s=20230601 header.b=zT2yUtVH;
dkim=pass header.i=@gmail.com header.s=20230601 header.b=nmJW8N67;
spf=pass (google.com: domain of tconvertino@gmail.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=tconvertino@gmail.com;
dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com;
dara=pass header.i=@gmail.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1748873190; x=1749477990;
h=to:from:subject:date:message-id:auto-submitted:sender:reply-to
:mime-version:dkim-signature:dkim-signature:delivered-to
:x-forwarded-for:x-forwarded-to:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=dgRmOj3aABlB3SNw+xxlI8L9ugJFZ1WMJrtLw/W8tnA=;
b=dBjp6JdmFUj0jKPDo9r2/xvfVSvxKaF15UYwYU7itdM18qpCnrgQdHMP2ST7EQBxou
58yZfVjrx84gg9phedpVSg4SaBaPIhXsLuUeVQZtPd7J3WYiH4+OGcecjV+cD0dG0TUi
o/FbZULNl3REysvoAj+AwUL/ny2FnNU4PIhkeSq+d6iNztkexIKLS8qWqHosenPlVX+E
Z7OGQZpK6m1LB5UbCsaODQq5wbNIxlOxqTP1rCHe/hHk53ljiNegzaOS31mVvp1n8/g1
pWIZltyZORs0zi6U9+mNd9ZbaeQjHqBrcb2bsTxCD+u0DBuF2RjLguS/feaB25TG8LAg
szYg==
X-Forwarded-Encrypted: i=2; AJvYcCXfGRAIDqrPsT1vzTMSiuMrlTj/DbRrr+8w7X+iLRH2XK/n8MZhV3UaT0Zia6c6jMrf3s3eHA==@xinu.tv
X-Gm-Message-State: AOJu0YxOQEmNiUg4NKf4NM1BgQMqTJaFM6txPnL6u74ff1dZvoSgTC4d
TtJJqfdHsajxloSGDsSPqIQ/M/Se/sfymEExFQxDXYA/XasA6+sdye/Ihl9QekGJK9jet1VtQ3r
dcg89xnFcxezg3ji6xH8jnSULlp350K9K7LR0LfTQqg6e/BEKEF8XDaNgmJC+RQ==
X-Received: by 2002:a05:6512:2246:b0:553:35bb:f7b7 with SMTP id 2adb3069b0e04-55342f92776mr2472199e87.32.1748873190333;
Mon, 02 Jun 2025 07:06:30 -0700 (PDT)
X-Forwarded-To: gmail@xinu.tv
X-Forwarded-For: couchmoney@gmail.com gmail@xinu.tv
Delivered-To: couchmoney@gmail.com
Received: by 2002:ab3:7457:0:b0:2b1:14e:dc2b with SMTP id g23csp2818972lti;
Mon, 2 Jun 2025 07:06:29 -0700 (PDT)
X-Received: by 2002:a05:6602:6a8b:b0:86c:f898:74b8 with SMTP id ca18e2360f4ac-86d0521552emr1082401939f.10.1748873188734;
Mon, 02 Jun 2025 07:06:28 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1748873188; cv=none;
d=google.com; s=arc-20240605;
b=d2PNXrTE3VYjml3FmbC5rBW6XnsyuyVO3lPyM6VoVKFcvZ7a8tDRB+sh1ibo0D5Nvg
3i/Qon0RV401WFb9NQf5P048wpj19G8bOGPZUKMioBZcSxkr1RwH/GW6GBvGS+d+iqbW
43KWc6Px7RGOEeYfp8D88CuJ/5kMcsLMfDV1FRHo6T+chVY6c9fQkHjRreSGQcFXglt5
yaCpFKkAODO7rSHl2OW2kQ6eGgR0tUjb95+jdZXoU0GS3119CBYK9n9UhNaeXHIk/Zyy
f08r4Ce/m3Y6ISr4ovXxDeYNpeeUN1HT3XVyCVQJHjfWrHypKTiOt4q6yBhCgOgZTXJq
pL5A==;
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605;
h=to:from:subject:date:message-id:auto-submitted:sender:reply-to
:mime-version:dkim-signature:dkim-signature;
bh=dgRmOj3aABlB3SNw+xxlI8L9ugJFZ1WMJrtLw/W8tnA=;
fh=mbzrMIWIgWMC0ni1xEx+ViW4J0RLAdLdPT2cX81nTlk=;
b=YiMakYeE05UctWy9sW90/a3l1Hk1pAPv0+fpk5vmWrADcMwwI8cHVqBp+Nxds5psWa
a/zrw9UlxV4HgjLUP+ella/pK8XxK+sitKg0IhPOntwKbq1KfTNheufh4HtWj5yWedHE
sO/dVs6z/EW/gWrfBK/3JMgsnz3HrHmaoJ6caCaGI6t5jHxEXI+eJc5zILY+n0MdivkX
tJOo0L1s/k6MAdyLr4/IVqpxdhXbUPq44twCBNheHd8T5w1DC9ZXcr54X79fW8Vzbm8/
A++H3gnZRGtOayRySYQl04LFLk4YsisdhsKuaJV+WKYCW58wQqJT04mrVkx+m96qr1q0
BQtw==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@google.com header.s=20230601 header.b=zT2yUtVH;
dkim=pass header.i=@gmail.com header.s=20230601 header.b=nmJW8N67;
spf=pass (google.com: domain of tconvertino@gmail.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=tconvertino@gmail.com;
dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com;
dara=pass header.i=@gmail.com
Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73])
by mx.google.com with SMTPS id ca18e2360f4ac-86d0213d491sor465078439f.8.2025.06.02.07.06.28
for <couchmoney@gmail.com>
(Google Transport Security);
Mon, 02 Jun 2025 07:06:28 -0700 (PDT)
Received-SPF: pass (google.com: domain of tconvertino@gmail.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73;
Authentication-Results: mx.google.com;
dkim=pass header.i=@google.com header.s=20230601 header.b=zT2yUtVH;
dkim=pass header.i=@gmail.com header.s=20230601 header.b=nmJW8N67;
spf=pass (google.com: domain of tconvertino@gmail.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=tconvertino@gmail.com;
dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com;
dara=pass header.i=@gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=google.com; s=20230601; t=1748873188; x=1749477988; dara=google.com;
h=to:from:subject:date:message-id:auto-submitted:sender:reply-to
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=dgRmOj3aABlB3SNw+xxlI8L9ugJFZ1WMJrtLw/W8tnA=;
b=zT2yUtVHhNy5fFiy6YKzfYCQPlCnufAEoWmbvjvj7mFNYUlLJHZ5FUeNnDs06Z1icR
bSVtejKixrz4hjFh9KeKvV9EQNGU7UFgySwqdy6szm+sHZQj+iJAXy85A1QaL6+0Swup
2y8QsjVJ96uugM0SaAYZqe+lmLBk6zFWqkg0U37vgwOupAcNsNBd7tos7cxO5eK6Aops
FJjr9JAD+ddX03ngH9zfnvlNV/+qbmiP6Hs8OmaJtZof2GLucpHgqUpIdolCh7F72v4p
DibO4RShI/IQCw9ejZxhRPBPWQwIdOYLjD/sDunX63M4NCS/63jZfhwqsAVgtmN/cUGq
spHQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1748873188; x=1749477988; dara=google.com;
h=to:from:subject:date:message-id:auto-submitted:sender:reply-to
:mime-version:from:to:cc:subject:date:message-id:reply-to;
bh=dgRmOj3aABlB3SNw+xxlI8L9ugJFZ1WMJrtLw/W8tnA=;
b=nmJW8N67IylgMNprzzf/IC7V2r7xeY0+8Bl0KcAak6Xly+IhVv3nyccvgdKsp+8Ccd
NcikfVOtCsE3gTqviReUbTAKy7PyClAbBTEHC0Ne71549BN+v8zX64RpGDFJGX5pJMG5
r0Ak88nxzjWkvDLhlnHmWdt/NggdQEI6T7oP4VZo0f0/Ym7g1WJhSItfdIhSRDNzK3ed
WPRXUIb1sW3+N0My4Os6L4IA9kdRk5z0qpQxtsIL9N0dzv4q18q6eH3KfTzVPr59PsYT
uSgkWoLQZdfA70MMlIRU5CnGbVDRH4TO/ib433vIblOmtLTkQ4EaOTzncbs0tovVes4z
evsQ==
X-Google-Smtp-Source: AGHT+IETNpLvkLm7t8VAdDcEcVtxFCttPh/uVZhoQCRlhUNlx9bmg67olJiD9EOND8g0z43NnM8iK4FxezZondExIawx
MIME-Version: 1.0
X-Received: by 2002:a05:6602:4183:b0:864:4a1b:dfc5 with SMTP id
ca18e2360f4ac-86d052154eamr1431889339f.9.1748873188195; Mon, 02 Jun 2025
07:06:28 -0700 (PDT)
Reply-To: tconvertino@gmail.com
Sender: Google Calendar <calendar-notification@google.com>
Auto-Submitted: auto-generated
Message-ID: <calendar-093be1c9-5d94-4994-8bc5-7daa1cfae47b@google.com>
Date: Mon, 02 Jun 2025 14:06:28 +0000
Subject: New event: Tamara and Scout in Alaska @ Tue Jun 24 - Mon Jun 30, 2025 (tconvertino@gmail.com)
From: tconvertino@gmail.com
To: couchmoney@gmail.com
Content-Type: multipart/alternative; boundary="00000000000023c70606369745e9"
--00000000000023c70606369745e9
Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes
Content-Transfer-Encoding: base64
VGFtYXJhIGFuZCBTY291dCBpbiBBbGFza2ENClR1ZXNkYXkgSnVuIDI0IOKAkyBNb25kYXkgSnVu
IDMwLCAyMDI1DQoNCg0KDQpPcmdhbml6ZXINCnRjb252ZXJ0aW5vQGdtYWlsLmNvbQ0KdGNvbnZl
cnRpbm9AZ21haWwuY29tDQoNCn5+Ly9+fg0KSW52aXRhdGlvbiBmcm9tIEdvb2dsZSBDYWxlbmRh
cjogaHR0cHM6Ly9jYWxlbmRhci5nb29nbGUuY29tL2NhbGVuZGFyLw0KDQpZb3UgYXJlIHJlY2Vp
dmluZyB0aGlzIGVtYWlsIGJlY2F1c2UgeW91IGFyZSBzdWJzY3JpYmVkIHRvIGNhbGVuZGFyICAN
Cm5vdGlmaWNhdGlvbnMuIFRvIHN0b3AgcmVjZWl2aW5nIHRoZXNlIGVtYWlscywgZ28gdG8gIA0K
aHR0cHM6Ly9jYWxlbmRhci5nb29nbGUuY29tL2NhbGVuZGFyL3Ivc2V0dGluZ3MsIHNlbGVjdCB0
aGlzIGNhbGVuZGFyLCBhbmQgIA0KY2hhbmdlICJPdGhlciBub3RpZmljYXRpb25zIi4NCg0KRm9y
d2FyZGluZyB0aGlzIGludml0YXRpb24gY291bGQgYWxsb3cgYW55IHJlY2lwaWVudCB0byBzZW5k
IGEgcmVzcG9uc2UgdG8gIA0KdGhlIG9yZ2FuaXplciwgYmUgYWRkZWQgdG8gdGhlIGd1ZXN0IGxp
c3QsIGludml0ZSBvdGhlcnMgcmVnYXJkbGVzcyBvZiAgDQp0aGVpciBvd24gaW52aXRhdGlvbiBz
dGF0dXMsIG9yIG1vZGlmeSB5b3VyIFJTVlAuDQoNCkxlYXJuIG1vcmUgaHR0cHM6Ly9zdXBwb3J0
Lmdvb2dsZS5jb20vY2FsZW5kYXIvYW5zd2VyLzM3MTM1I2ZvcndhcmRpbmcNCg==
--00000000000023c70606369745e9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<!doctype html><html xmlns=3D"http://www.w3.org/1999/xhtml" xmlns:v=3D"urn:="...truncated for brevity...

57
server/testdata/ical-example-1.ics vendored Normal file
View File

@ -0,0 +1,57 @@
BEGIN:VCALENDAR
METHOD:REQUEST
PRODID:Microsoft Exchange Server 2010
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Pacific Standard Time
BEGIN:STANDARD
DTSTART:16010101T020000
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
ORGANIZER;CN=Bill Thiede:mailto:wthiede@nvidia.com
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Bill:mailt
o:couchmoney@gmail.com
DESCRIPTION;LANGUAGE=en-US:\n
UID:040000008200E00074C5B7101A82E00800000000A1458AEA8E4DDB01000000000000000
010000000988BC323BE65A8458B718B5EF8FE8152
SUMMARY;LANGUAGE=en-US:dentist night guard
DTSTART;TZID=Pacific Standard Time:20250108T080000
DTEND;TZID=Pacific Standard Time:20250108T090000
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20241213T184408Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
LOCATION;LANGUAGE=en-US:
X-MICROSOFT-CDO-APPT-SEQUENCE:0
X-MICROSOFT-CDO-OWNERAPPTID:2123132523
X-MICROSOFT-CDO-BUSYSTATUS:TENTATIVE
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-ONLINEMEETINGEXTERNALLINK:
X-MICROSOFT-ONLINEMEETINGCONFLINK:
X-MICROSOFT-DONOTFORWARDMEETING:FALSE
X-MICROSOFT-DISALLOW-COUNTER:FALSE
X-MICROSOFT-REQUESTEDATTENDANCEMODE:DEFAULT
X-MICROSOFT-ISRESPONSEREQUESTED:TRUE
X-MICROSOFT-LOCATIONS:[]
BEGIN:VALARM
DESCRIPTION:REMINDER
TRIGGER;RELATED=START:-PT5M
ACTION:DISPLAY
END:VALARM
END:VEVENT
END:VCALENDAR

30
server/testdata/ical-example-2.ics vendored Normal file
View File

@ -0,0 +1,30 @@
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REPLY
X-GOOGLE-CALID:g66m0feuqsao8l1c767pvvcg4k@group.calendar.google.com
BEGIN:VEVENT
DTSTART:20250813T010000Z
DTEND:20250813T030000Z
DTSTAMP:20250801T022550Z
ORGANIZER;CN=Family:mailto:g66m0feuqsao8l1c767pvvcg4k@group.calendar.google
.com
UID:6os3ap346th6ab9nckp30b9kc8sm2bb160q3gb9l6lgm6or160rjee1mco@google.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=superm
atute@gmail.com;X-NUM-GUESTS=0:mailto:supermatute@gmail.com
X-GOOGLE-CONFERENCE:https://meet.google.com/dcu-hykx-vym
CREATED:20250801T015712Z
DESCRIPTION:-::~:~::~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~
:~:~:~:~:~:~:~:~::~:~::-\nJoin with Google Meet: https://meet.google.com/dc
u-hykx-vym\n\nLearn more about Meet at: https://support.google.com/a/users/
answer/9282720\n\nPlease do not edit this section.\n-::~:~::~:~:~:~:~:~:~:~
:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~::~:~::-
LAST-MODIFIED:20250801T022549Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:[tenative] dinner w/ amatute
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR

9
server/testdata/ical-multiday.ics vendored Normal file
View File

@ -0,0 +1,9 @@
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
SUMMARY:Multi-day Event
DTSTART;VALUE=DATE:20250828
DTEND;VALUE=DATE:20250831
DESCRIPTION:This event spans multiple days.
END:VEVENT
END:VCALENDAR

36
server/testdata/ical-straddle-real.ics vendored Normal file
View File

@ -0,0 +1,36 @@
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART;VALUE=DATE:20250830
DTEND;VALUE=DATE:20250902
DTSTAMP:20250819T183713Z
ORGANIZER;CN=Bill Thiede:mailto:couchmoney@gmail.com
UID:37kplskaimjnhdnt8r5ui9pv7f@google.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
TRUE;CN=bill@xinu.tv;X-NUM-GUESTS=0:mailto:bill@xinu.tv
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=TRUE
;CN=Bill Thiede;X-NUM-GUESTS=0:mailto:couchmoney@gmail.com
X-MICROSOFT-CDO-OWNERAPPTID:1427505964
CREATED:20250819T183709Z
DESCRIPTION:
LAST-MODIFIED:20250819T183709Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Test Straddle Month
TRANSP:TRANSPARENT
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:This is an event reminder
TRIGGER:-P0DT0H30M0S
END:VALARM
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:This is an event reminder
TRIGGER:-P0DT7H30M0S
END:VALARM
END:VEVENT
END:VCALENDAR

9
server/testdata/ical-straddle.ics vendored Normal file
View File

@ -0,0 +1,9 @@
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
SUMMARY:Straddle Month Event
DTSTART;VALUE=DATE:20250830
DTEND;VALUE=DATE:20250903
DESCRIPTION:This event straddles two months.
END:VEVENT
END:VCALENDAR

View File

@ -12,7 +12,7 @@ version.workspace = true
[dependencies] [dependencies]
build-info = "0.0.41" build-info = "0.0.41"
letterbox-notmuch = { path = "../notmuch", version = "0.17.34", registry = "xinu" } letterbox-notmuch = { path = "../notmuch", version = "0.17.36", registry = "xinu" }
regex = "1.11.1" regex = "1.11.1"
serde = { version = "1.0.219", features = ["derive"] } serde = { version = "1.0.219", features = ["derive"] }
sqlx = "0.8.5" sqlx = "0.8.5"

View File

@ -33,7 +33,7 @@ wasm-bindgen = "=0.2.100"
uuid = { version = "1.16.0", features = [ uuid = { version = "1.16.0", features = [
"js", "js",
] } # direct dep to set js feature, prevents Rng issues ] } # direct dep to set js feature, prevents Rng issues
letterbox-shared = { path = "../shared/", version = "0.17.34", registry = "xinu" } letterbox-shared = { path = "../shared/", version = "0.17.36", registry = "xinu" }
seed_hooks = { version = "0.4.1", registry = "xinu" } seed_hooks = { version = "0.4.1", registry = "xinu" }
strum_macros = "0.27.1" strum_macros = "0.27.1"
gloo-console = "0.3.0" gloo-console = "0.3.0"