[evolution] I#590 - Redirect should not modify message headers
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#590 - Redirect should not modify message headers
- Date: Tue, 18 Feb 2020 18:42:07 +0000 (UTC)
commit 170f7b296526d12f92e98f26ce8ce36e47a084cf
Author: Milan Crha <mcrha redhat com>
Date: Tue Feb 18 19:43:52 2020 +0100
I#590 - Redirect should not modify message headers
Closes https://gitlab.gnome.org/GNOME/evolution/issues/590
src/composer/e-msg-composer.c | 27 ++++++++++++++++++++++++---
src/libemail-engine/e-mail-folder-utils.c | 8 +++++---
src/libemail-engine/e-mail-session-utils.c | 3 ++-
src/libemail-engine/mail-ops.c | 3 ++-
4 files changed, 33 insertions(+), 8 deletions(-)
---
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index cd3168d882..7f3aee36ae 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -67,6 +67,7 @@ struct _AsyncContext {
GSList *recipients_with_certificate; /* EContact * */
guint skip_content : 1;
+ guint is_redirect : 1;
guint need_thread : 1;
guint pgp_sign : 1;
guint pgp_encrypt : 1;
@@ -543,7 +544,8 @@ build_message_headers (EMsgComposer *composer,
/* Subject: */
subject = e_composer_header_table_get_subject (table);
- camel_mime_message_set_subject (message, subject);
+ if (!redirect || g_strcmp0 (subject, camel_mime_message_get_subject (message)) != 0)
+ camel_mime_message_set_subject (message, subject);
if (source != NULL) {
CamelMedium *medium;
@@ -627,6 +629,9 @@ build_message_headers (EMsgComposer *composer,
g_object_unref (source);
}
+ if (redirect)
+ camel_medium_set_header (CAMEL_MEDIUM (message), "X-Evolution-Is-Redirect", "1");
+
/* Reply-To: */
reply_to = e_composer_header_table_get_reply_to (table);
if (reply_to != NULL && *reply_to != '\0') {
@@ -658,7 +663,22 @@ build_message_headers (EMsgComposer *composer,
}
/* Date: */
- camel_mime_message_set_date (message, CAMEL_MESSAGE_DATE_CURRENT, 0);
+ if (redirect) {
+ struct tm local;
+ gint tz, offset;
+ time_t date;
+ gchar *datestr;
+
+ date = time (NULL);
+ camel_localtime_with_offset (date, &local, &tz);
+ offset = (((tz / 60 / 60) * 100) + (tz / 60 % 60));
+
+ datestr = camel_header_format_date (date, offset);
+ camel_medium_set_header (CAMEL_MEDIUM (message), "Resent-Date", datestr);
+ g_free (datestr);
+ } else {
+ camel_mime_message_set_date (message, CAMEL_MESSAGE_DATE_CURRENT, 0);
+ }
/* X-Evolution-PostTo: */
header = e_composer_header_table_get_header (
@@ -1296,6 +1316,7 @@ composer_build_message (EMsgComposer *composer,
e_msg_composer_dec_soft_busy (composer);
context->skip_content = TRUE;
+ context->is_redirect = TRUE;
context->message = g_object_ref (priv->redirect);
build_message_headers (composer, context->message, TRUE);
g_simple_async_result_complete (simple);
@@ -1728,7 +1749,7 @@ composer_build_message_finish (EMsgComposer *composer,
}
}
- if (context->top_level_part == context->text_plain_part) {
+ if (!context->is_redirect && context->top_level_part == context->text_plain_part) {
camel_mime_part_set_encoding (
CAMEL_MIME_PART (context->message),
context->plain_encoding);
diff --git a/src/libemail-engine/e-mail-folder-utils.c b/src/libemail-engine/e-mail-folder-utils.c
index 505b9f4b6f..5f8922824d 100644
--- a/src/libemail-engine/e-mail-folder-utils.c
+++ b/src/libemail-engine/e-mail-folder-utils.c
@@ -107,10 +107,12 @@ e_mail_folder_append_message_sync (CamelFolder *folder,
full_display_name ? full_display_name : camel_folder_get_display_name (folder));
g_free (full_display_name);
- if (camel_medium_get_header (medium, "User-Agent") == NULL)
- camel_medium_set_header (medium, "User-Agent", USER_AGENT);
+ if (!camel_medium_get_header (medium, "X-Evolution-Is-Redirect")) {
+ if (camel_medium_get_header (medium, "User-Agent") == NULL)
+ camel_medium_set_header (medium, "User-Agent", USER_AGENT);
- camel_mime_message_set_date (message, CAMEL_MESSAGE_DATE_CURRENT, 0);
+ camel_mime_message_set_date (message, CAMEL_MESSAGE_DATE_CURRENT, 0);
+ }
success = camel_folder_append_message_sync (
folder, message, info, appended_uid, cancellable, error);
diff --git a/src/libemail-engine/e-mail-session-utils.c b/src/libemail-engine/e-mail-session-utils.c
index 3aaf924e0b..7be43cb85c 100644
--- a/src/libemail-engine/e-mail-session-utils.c
+++ b/src/libemail-engine/e-mail-session-utils.c
@@ -818,7 +818,8 @@ e_mail_session_send_to (EMailSession *session,
medium = CAMEL_MEDIUM (message);
- camel_medium_set_header (medium, "User-Agent", USER_AGENT);
+ if (!camel_medium_get_header (medium, "X-Evolution-Is-Redirect"))
+ camel_medium_set_header (medium, "User-Agent", USER_AGENT);
/* Do this before removing "X-Evolution" headers. */
transport = e_mail_session_ref_transport_for_message (
diff --git a/src/libemail-engine/mail-ops.c b/src/libemail-engine/mail-ops.c
index 028272ed01..aefa2ae6dd 100644
--- a/src/libemail-engine/mail-ops.c
+++ b/src/libemail-engine/mail-ops.c
@@ -598,7 +598,8 @@ mail_send_message (struct _send_queue_msg *m,
if (!message)
return;
- camel_medium_set_header (CAMEL_MEDIUM (message), "User-Agent", USER_AGENT);
+ if (!camel_medium_get_header (CAMEL_MEDIUM (message), "X-Evolution-Is-Redirect"))
+ camel_medium_set_header (CAMEL_MEDIUM (message), "User-Agent", USER_AGENT);
/* Do this before removing "X-Evolution" headers. */
service = e_mail_session_ref_transport_for_message (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]