FIX: always set a default Message ID in email

This commit is contained in:
Arpit Jalan 2015-01-28 14:42:49 +05:30
parent 3483c8318f
commit b0369061e2
2 changed files with 9 additions and 0 deletions

View File

@ -70,6 +70,10 @@ module Email
post_id = header_value('X-Discourse-Post-Id') post_id = header_value('X-Discourse-Post-Id')
reply_key = header_value('X-Discourse-Reply-Key') reply_key = header_value('X-Discourse-Reply-Key')
# always set a default Message ID from the host
uuid = SecureRandom.uuid
@message.header['Message-ID'] = "<#{uuid}@#{host}>"
if topic_id.present? if topic_id.present?
email_log.topic_id = topic_id email_log.topic_id = topic_id

View File

@ -73,6 +73,11 @@ describe Email::Sender do
Then { expect(message.header['List-ID']).to be_present } Then { expect(message.header['List-ID']).to be_present }
end end
context "adds a Message-ID header even when topic id is not present" do
When { email_sender.send }
Then { expect(message.header['Message-ID']).to be_present }
end
context "adds Precedence header" do context "adds Precedence header" do
before do before do
message.header['X-Discourse-Topic-Id'] = 5577 message.header['X-Discourse-Topic-Id'] = 5577