diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 1db1482d6b7..0e1e39501f5 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -124,7 +124,7 @@ class Notify < BaseMailer fallback_reply_message_id = "".freeze headers['References'] ||= [] - headers['References'] << fallback_reply_message_id + headers['References'].unshift(fallback_reply_message_id) @reply_by_email = true end @@ -158,7 +158,7 @@ class Notify < BaseMailer def mail_answer_thread(model, headers = {}) headers['Message-ID'] = "<#{SecureRandom.hex}@#{Gitlab.config.gitlab.host}>" headers['In-Reply-To'] = message_id(model) - headers['References'] = message_id(model) + headers['References'] = [message_id(model)] headers[:subject]&.prepend('Re: ') diff --git a/changelogs/unreleased/tc-reorder-mail-notify-references.yml b/changelogs/unreleased/tc-reorder-mail-notify-references.yml new file mode 100644 index 00000000000..689afda0259 --- /dev/null +++ b/changelogs/unreleased/tc-reorder-mail-notify-references.yml @@ -0,0 +1,5 @@ +--- +title: Put fallback reply-key address first in the References header +merge_request: 20871 +author: +type: changed diff --git a/spec/fixtures/emails/commands_in_reply.eml b/spec/fixtures/emails/commands_in_reply.eml index 712f6f797b4..6a467ccbbc6 100644 --- a/spec/fixtures/emails/commands_in_reply.eml +++ b/spec/fixtures/emails/commands_in_reply.eml @@ -8,7 +8,7 @@ From: Jake the Dog To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo Message-ID: In-Reply-To: -References: +References: Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux' Mime-Version: 1.0 Content-Type: text/plain; diff --git a/spec/fixtures/emails/commands_only_reply.eml b/spec/fixtures/emails/commands_only_reply.eml index 2d2e2f94290..9b8d25c406e 100644 --- a/spec/fixtures/emails/commands_only_reply.eml +++ b/spec/fixtures/emails/commands_only_reply.eml @@ -8,7 +8,7 @@ From: Jake the Dog To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo Message-ID: In-Reply-To: -References: +References: Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux' Mime-Version: 1.0 Content-Type: text/plain; diff --git a/spec/fixtures/emails/reply_without_subaddressing_and_key_inside_references.eml b/spec/fixtures/emails/reply_without_subaddressing_and_key_inside_references.eml index 39d5cefbc2a..609d9d9e93d 100644 --- a/spec/fixtures/emails/reply_without_subaddressing_and_key_inside_references.eml +++ b/spec/fixtures/emails/reply_without_subaddressing_and_key_inside_references.eml @@ -8,7 +8,7 @@ From: Jake the Dog To: reply@appmail.adventuretime.ooo Message-ID: In-Reply-To: -References: +References: Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux' Mime-Version: 1.0 Content-Type: text/plain; diff --git a/spec/fixtures/emails/reply_without_subaddressing_and_key_inside_references_with_a_comma.eml b/spec/fixtures/emails/reply_without_subaddressing_and_key_inside_references_with_a_comma.eml index 6823db0cfc8..7be1ed5bf44 100644 --- a/spec/fixtures/emails/reply_without_subaddressing_and_key_inside_references_with_a_comma.eml +++ b/spec/fixtures/emails/reply_without_subaddressing_and_key_inside_references_with_a_comma.eml @@ -8,7 +8,7 @@ From: Jake the Dog To: reply@appmail.adventuretime.ooo Message-ID: In-Reply-To: -References: , +References: , Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux' Mime-Version: 1.0 Content-Type: text/plain; diff --git a/spec/fixtures/emails/update_commands_only_reply.eml b/spec/fixtures/emails/update_commands_only_reply.eml index bb0d2b0e03a..927a62f6475 100644 --- a/spec/fixtures/emails/update_commands_only_reply.eml +++ b/spec/fixtures/emails/update_commands_only_reply.eml @@ -8,7 +8,7 @@ From: Jake the Dog To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo Message-ID: In-Reply-To: -References: +References: Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux' Mime-Version: 1.0 Content-Type: text/plain; diff --git a/spec/fixtures/emails/valid_reply.eml b/spec/fixtures/emails/valid_reply.eml index 980e10a8812..5fbeebdb6b0 100644 --- a/spec/fixtures/emails/valid_reply.eml +++ b/spec/fixtures/emails/valid_reply.eml @@ -8,7 +8,7 @@ From: Jake the Dog To: reply+59d8df8370b7e95c5a49fbf86aeb2c93@appmail.adventuretime.ooo Message-ID: In-Reply-To: -References: +References: Subject: re: [Discourse Meta] eviltrout posted in 'Adventure Time Sux' Mime-Version: 1.0 Content-Type: text/plain; diff --git a/spec/support/shared_examples/notify_shared_examples.rb b/spec/support/shared_examples/notify_shared_examples.rb index d176d3fa425..5beae005cf7 100644 --- a/spec/support/shared_examples/notify_shared_examples.rb +++ b/spec/support/shared_examples/notify_shared_examples.rb @@ -77,7 +77,7 @@ shared_examples 'a thread answer email with reply-by-email enabled' do aggregate_failures do is_expected.to have_header('Message-ID', /\A<.*@#{host}>\Z/) is_expected.to have_header('In-Reply-To', "<#{route_key}@#{host}>") - is_expected.to have_header('References', /\A<#{route_key}@#{host}> \Z/ ) + is_expected.to have_header('References', /\A <#{route_key}@#{host}>\Z/ ) is_expected.to have_subject(/^Re: /) end end