FIX: remove custom Discourse headers in email

This commit is contained in:
Arpit Jalan 2015-01-29 17:23:10 +05:30
parent 6856c0a511
commit e97755ab5d
2 changed files with 21 additions and 3 deletions

View File

@ -117,9 +117,9 @@ module Email
email_log.reply_key = reply_key if reply_key.present?
# Remove headers we don't need anymore
@message.header['X-Discourse-Topic-Id'] = nil
@message.header['X-Discourse-Post-Id'] = nil
@message.header['X-Discourse-Reply-Key'] = nil
@message.header['X-Discourse-Topic-Id'] = nil if topic_id.present?
@message.header['X-Discourse-Post-Id'] = nil if post_id.present?
@message.header['X-Discourse-Reply-Key'] = nil if reply_key.present?
# Suppress images from short emails
if SiteSetting.strip_images_from_short_emails && @message.html_part.body.to_s.bytesize <= SiteSetting.short_email_length && @message.html_part.body =~ /<img[^>]+>/

View File

@ -87,6 +87,24 @@ describe Email::Sender do
Then { expect(message.header['Precedence']).to be_present }
end
context "removes custom Discourse headers from topic notification mails" do
before do
message.header['X-Discourse-Topic-Id'] = 5577
end
When { email_sender.send }
Then { expect(message.header['X-Discourse-Topic-Id']).not_to be_present }
Then { expect(message.header['X-Discourse-Post-Id']).not_to be_present }
Then { expect(message.header['X-Discourse-Reply-Key']).not_to be_present }
end
context "removes custom Discourse headers from digest/registration/other mails" do
When { email_sender.send }
Then { expect(message.header['X-Discourse-Topic-Id']).not_to be_present }
Then { expect(message.header['X-Discourse-Post-Id']).not_to be_present }
Then { expect(message.header['X-Discourse-Reply-Key']).not_to be_present }
end
context 'email logs' do
let(:email_log) { EmailLog.last }