mu: fake reply-to for mailing-list posts
Some mailing lists do _not_ set reply-to, see e.g., https://github.com/djcb/mu/pull/1278 In that case, use the 'List-Post' address instead, so the behavior is the same (in mu4e) as for other mailing lists.
This commit is contained in:
@ -46,9 +46,6 @@ append_sexp_attr_list (GString *gstr, const char* elm, const GSList *lst)
|
||||
g_string_append (gstr, ")\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
append_sexp_attr (GString *gstr, const char* elm, const char *str)
|
||||
{
|
||||
@ -71,7 +68,6 @@ append_sexp_attr (GString *gstr, const char* elm, const char *str)
|
||||
g_free (esc);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
append_sexp_body_attr (GString *gstr, const char* elm, const char *str)
|
||||
{
|
||||
@ -86,11 +82,6 @@ append_sexp_body_attr (GString *gstr, const char* elm, const char *str)
|
||||
g_free (esc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct _ContactData {
|
||||
gboolean from, to, cc, bcc, reply_to;
|
||||
GString *gstr;
|
||||
@ -118,6 +109,7 @@ get_name_addr_pair (MuMsgContact *c)
|
||||
return pair;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_prefix_maybe (GString *gstr, gboolean *field, const char *prefix)
|
||||
{
|
||||
@ -172,6 +164,36 @@ each_contact (MuMsgContact *c, ContactData *cdata)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
maybe_append_list_post_as_reply_to (GString *gstr, MuMsg *msg)
|
||||
{
|
||||
/* some mailing lists do not set the reply-to; see pull #1278. So for
|
||||
* those cases, check the List-Post address and use that instead */
|
||||
|
||||
GMatchInfo *minfo;
|
||||
GRegex *rx;
|
||||
const char* list_post;
|
||||
|
||||
list_post = mu_msg_get_header (msg, "List-Post");
|
||||
if (!list_post)
|
||||
return;
|
||||
|
||||
rx = g_regex_new ("^(<?mailto:)?([a-z0-9%+@.-]+)>?", G_REGEX_CASELESS, 0, NULL);
|
||||
g_return_if_fail(rx);
|
||||
|
||||
if (g_regex_match (rx, list_post, 0, &minfo)) {
|
||||
char *addr;
|
||||
addr = g_match_info_fetch (minfo, 2);
|
||||
g_string_append_printf (gstr,"\t:reply-to ((nil . \"%s\"))\n", addr);
|
||||
g_free(addr);
|
||||
}
|
||||
|
||||
g_match_info_free (minfo);
|
||||
g_regex_unref (rx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
append_sexp_contacts (GString *gstr, MuMsg *msg)
|
||||
{
|
||||
@ -184,9 +206,11 @@ append_sexp_contacts (GString *gstr, MuMsg *msg)
|
||||
|
||||
mu_msg_contact_foreach (msg, (MuMsgContactForeachFunc)each_contact,
|
||||
&cdata);
|
||||
|
||||
if (cdata.from || cdata.to || cdata.cc || cdata.bcc || cdata.reply_to)
|
||||
gstr = g_string_append (gstr, ")\n");
|
||||
|
||||
if (!cdata.reply_to)
|
||||
maybe_append_list_post_as_reply_to (gstr, msg);
|
||||
}
|
||||
|
||||
struct _FlagData {
|
||||
@ -557,7 +581,6 @@ append_sexp_tags (GString *gstr, MuMsg *msg)
|
||||
g_string_free (tagstr, TRUE);
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
mu_msg_to_sexp (MuMsg *msg, unsigned docid, const MuMsgIterThreadInfo *ti,
|
||||
MuMsgOptions opts)
|
||||
@ -580,9 +603,8 @@ mu_msg_to_sexp (MuMsg *msg, unsigned docid, const MuMsgIterThreadInfo *ti,
|
||||
|
||||
append_sexp_attr (gstr, "subject", mu_msg_get_subject (msg));
|
||||
|
||||
/* in the no-headers-only case (see below) we get a more
|
||||
* complete list of contacts, so no need to get them here if
|
||||
* that's the case */
|
||||
/* in the no-headers-only case (see below) we get a more complete list
|
||||
* of contacts, so no need to get them here if that's the case */
|
||||
if (opts & MU_MSG_OPTION_HEADERS_ONLY)
|
||||
append_sexp_contacts (gstr, msg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user