From 7d48a403f792b4b0fb82e64d9f57a90fbc1b1933 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 2 Sep 2008 17:41:36 +0000 Subject: [PATCH] Implemented RFC2919, the 'List-ID' field for mailing lists. This is now a top-level Citadel header field (L), which makes it parseable by the Sieve engine. Also added List-ID to the header fields selectable in the mailbox filter rules editor. And of course, we are generating this field when we send out traffic from a Citadel-hosted mailing list. This also closes Bug #371. --- citadel/internet_addressing.c | 6 ++++++ citadel/modules/network/serv_network.c | 21 +++++++++++++++++++++ citadel/msgbase.c | 3 +++ citadel/techdoc/hack.txt | 1 + webcit/sieve.c | 14 +++++++++++--- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index c96d722e1..8661d70fa 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -600,6 +600,12 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { processed = 1; } + else if (!strcasecmp(key, "List-ID")) { + if (msg->cm_fields['L'] == NULL) + msg->cm_fields['L'] = strdup(value); + processed = 1; + } + else if (!strcasecmp(key, "To")) { if (msg->cm_fields['R'] == NULL) msg->cm_fields['R'] = strdup(value); diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index 86102e0a3..b71d95a5f 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -478,6 +478,15 @@ void network_deliver_digest(SpoolControl *sc) { msg->cm_fields['F'] = strdup(buf); msg->cm_fields['R'] = strdup(buf); + /* Set the 'List-ID' header */ + msg->cm_fields['L'] = malloc(1024); + snprintf(msg->cm_fields['L'], 1024, + "%s <%ld.list-id.%s>", + CC->room.QRname, + CC->room.QRnumber, + config.c_fqdn + ); + /* * Go fetch the contents of the digest */ @@ -610,6 +619,18 @@ void network_spool_msg(long msgnum, void *userdata) { msg = CtdlFetchMessage(msgnum, 1); if (msg != NULL) { + /* Set the 'List-ID' header */ + if (msg->cm_fields['L'] != NULL) { + free(msg->cm_fields['L']); + } + msg->cm_fields['L'] = malloc(1024); + snprintf(msg->cm_fields['L'], 1024, + "%s <%ld.list-id.%s>", + CC->room.QRname, + CC->room.QRnumber, + config.c_fqdn + ); + /* Prepend "[List name]" to the subject */ if (msg->cm_fields['U'] == NULL) { msg->cm_fields['U'] = strdup("(no subject)"); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index ebf44c4d3..2324ee694 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -1776,6 +1776,9 @@ int CtdlOutputPreLoadedMsg( else if (i == 'P') { cprintf("Return-Path: %s%s", mptr, nl); } + else if (i == 'L') { + cprintf("List-ID: %s%s", mptr, nl); + } else if (i == 'V') { if ((flags & QP_EADDR) != 0) mptr = qp_encode_email_addrs(mptr); diff --git a/citadel/techdoc/hack.txt b/citadel/techdoc/hack.txt index 21ad22039..52bbcb0e5 100644 --- a/citadel/techdoc/hack.txt +++ b/citadel/techdoc/hack.txt @@ -260,6 +260,7 @@ J Journal The presence of this field indicates that the message is disqualified from being journaled, perhaps because it is itself a journalized message and we wish to avoid double journaling. +L List-ID Mailing list identification, as per RFC 2919 M Message Text Normal ASCII, newlines seperated by CR's or LF's, null terminated as always. N Nodename Contains node name of system message originated on. diff --git a/webcit/sieve.c b/webcit/sieve.c index 370f3c611..0f9687d35 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -355,6 +355,13 @@ void output_sieve_rule(char *hfield, char *compare, char *htext, char *sizecomp, ); } + else if (!strcasecmp(hfield, "listid")) { + serv_printf("if%s header %s \"List-ID\" \"%s\"", + comp1, comp2, + htext + ); + } + else if (!strcasecmp(hfield, "envfrom")) { serv_printf("if%s envelope %s \"From\" \"%s\"", comp1, comp2, @@ -539,7 +546,7 @@ void parse_fields_from_rule_editor(void) { serv_printf("# WEBCIT_RULE|%d|%s|", i, encoded_rule); output_sieve_rule(hfield, compare, htext, sizecomp, sizeval, action, fileinto, redirect, automsg, final, my_addresses); - serv_printf(""); + serv_puts(""); } @@ -983,7 +990,7 @@ void display_rules_editor_inner_div(void) { wprintf("%s ", _("If") ); - char *hfield_values[14][2] = { + char *hfield_values[15][2] = { { "from", _("From") }, { "tocc", _("To or Cc") }, { "subject", _("Subject") }, @@ -996,13 +1003,14 @@ void display_rules_editor_inner_div(void) { { "xmailer", _("X-Mailer") }, { "xspamflag", _("X-Spam-Flag") }, { "xspamstatus", _("X-Spam-Status") }, + { "listid", _("List-ID") }, { "size", _("Message size") }, { "all", _("All") } }; wprintf("