cli/reply: reorganize create_reply_message()

Again, in preparation for later unification, reorganize
create_reply_message() to be more similar to the headers-only format
reply code in notmuch_reply_format_headers_only(). Due to "pretty"
header ordering, there should be no change in output. There should be
no functional changes.
This commit is contained in:
Jani Nikula 2016-09-13 20:14:13 +03:00 committed by David Bremner
parent 208053b684
commit b1aca0e502

View file

@ -532,12 +532,20 @@ create_reply_message(void *ctx,
return NULL; return NULL;
} }
subject = notmuch_message_get_header (message, "subject"); in_reply_to = talloc_asprintf (ctx, "<%s>",
if (subject) { notmuch_message_get_message_id (message));
if (strncasecmp (subject, "Re:", 3))
subject = talloc_asprintf (ctx, "Re: %s", subject); g_mime_object_set_header (GMIME_OBJECT (reply), "In-Reply-To", in_reply_to);
g_mime_message_set_subject (reply, subject);
} orig_references = notmuch_message_get_header (message, "references");
if (!orig_references)
/* Treat errors like missing References headers. */
orig_references = "";
references = talloc_asprintf (ctx, "%s%s%s",
*orig_references ? orig_references : "",
*orig_references ? " " : "",
in_reply_to);
g_mime_object_set_header (GMIME_OBJECT (reply), "References", references);
from_addr = add_recipients_from_message (reply, config, from_addr = add_recipients_from_message (reply, config,
message, reply_all); message, reply_all);
@ -572,25 +580,14 @@ create_reply_message(void *ctx,
from_addr = talloc_asprintf (ctx, "%s <%s>", from_addr = talloc_asprintf (ctx, "%s <%s>",
notmuch_config_get_user_name (config), notmuch_config_get_user_name (config),
from_addr); from_addr);
g_mime_object_set_header (GMIME_OBJECT (reply), g_mime_object_set_header (GMIME_OBJECT (reply), "From", from_addr);
"From", from_addr);
in_reply_to = talloc_asprintf (ctx, "<%s>", subject = notmuch_message_get_header (message, "subject");
notmuch_message_get_message_id (message)); if (subject) {
if (strncasecmp (subject, "Re:", 3))
g_mime_object_set_header (GMIME_OBJECT (reply), subject = talloc_asprintf (ctx, "Re: %s", subject);
"In-Reply-To", in_reply_to); g_mime_message_set_subject (reply, subject);
}
orig_references = notmuch_message_get_header (message, "references");
if (!orig_references)
/* Treat errors like missing References headers. */
orig_references = "";
references = talloc_asprintf (ctx, "%s%s%s",
*orig_references ? orig_references : "",
*orig_references ? " " : "",
in_reply_to);
g_mime_object_set_header (GMIME_OBJECT (reply),
"References", references);
return reply; return reply;
} }