From f789de70449718f8844376deb5bf5b86d3a9bd63 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 26 Feb 2021 15:21:26 +0100 Subject: [PATCH] get mailinglist name from From: if sender indicates a notification list --- src/dc_receive_imf.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index f26102066..729ecfd54 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -1539,6 +1539,24 @@ async fn create_or_lookup_mailinglist( name = cap[1].to_string(); } + // if we do not have a name yet and `From` indicates, that this is a notification list, + // a usable name is often in the `From` header. + // this pattern was seen for parcel service notifications + // and is similar to mailchimp above, however, with weaker conditions. + if name.is_empty() { + if let Some(from) = mime_parser.from.first() { + if from.addr.contains("noreply") + || from.addr.contains("no-reply") + || from.addr.starts_with("notifications@") + { + if let Some(display_name) = &from.display_name { + name = display_name.clone(); + } + } + } + } + + // as a last resort, use the ListId as the name if name.is_empty() { name = listid.clone(); }