message: flag list-unsubscribe as MailingList

Flag message that merely have a List-Unsubscribe header with
Flags::MailingList too (some marketing message have this header, yet
miss "List-Id".

Add a test as well.
This commit is contained in:
Dirk-Jan C. Binnema
2024-03-15 19:23:35 +02:00
parent 9fd0d2be12
commit 52826aa758
2 changed files with 31 additions and 2 deletions

View File

@ -326,8 +326,16 @@ get_mailing_list(const MimeMessage& mime_msg)
const char *b, *e;
const auto hdr{mime_msg.header("List-Id")};
if (!hdr)
return {};
if (!hdr) {
/* some marketing messages don't have a List-Id, but _do_ have a
* List-Unsubscribe; if so, return an empty string here, so this
* message is still flagged as "MailingList"
*/
if (const auto lu = mime_msg.header("List-Unsubscribe"); !!lu)
return "";
else
return Nothing;
}
dechdr = g_mime_utils_header_decode_phrase(NULL, hdr->c_str());
if (!dechdr)