From beaa1455729c8a442e37e9f23d908fa7677ce0cb Mon Sep 17 00:00:00 2001 From: Jeff Atwood Date: Fri, 13 Jun 2014 15:42:14 -0700 Subject: [PATCH] some email notification header fixes --- lib/email/sender.rb | 21 ++++++++++----------- spec/components/email/sender_spec.rb | 14 -------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/lib/email/sender.rb b/lib/email/sender.rb index 48b3228816e..2bfbae96717 100644 --- a/lib/email/sender.rb +++ b/lib/email/sender.rb @@ -58,8 +58,6 @@ module Email host = Email::Sender.host_for(Discourse.base_url) - @message.header['List-Id'] = Email::Sender.list_id_for(SiteSetting.title, host) - topic_id = header_value('X-Discourse-Topic-Id') post_id = header_value('X-Discourse-Post-Id') reply_key = header_value('X-Discourse-Reply-Key') @@ -67,9 +65,16 @@ module Email if topic_id.present? email_log.topic_id = topic_id - topic_identitfier = "" - @message.header['In-Reply-To'] = topic_identitfier - @message.header['References'] = topic_identitfier + topic_identifier = "" + @message.header['In-Reply-To'] = topic_identifier + @message.header['References'] = topic_identifier + + # http://www.ietf.org/rfc/rfc2919.txt + @message.header['List-ID'] = "" + # can't figure out how to get the current URL of the topic here + #@message.header['List-Archive'] = + # in github notifications, these fields are identical + @message.header['List-Post'] = @message.header['Reply-To'] end email_log.post_id = post_id if post_id.present? @@ -110,12 +115,6 @@ module Email host end - def self.list_id_for(site_name, host) - "\"#{site_name.gsub(/\"/, "'")}\" " - end - - - private def header_value(name) diff --git a/spec/components/email/sender_spec.rb b/spec/components/email/sender_spec.rb index c13342b5379..8c4a8e3d65e 100644 --- a/spec/components/email/sender_spec.rb +++ b/spec/components/email/sender_spec.rb @@ -39,20 +39,6 @@ describe Email::Sender do end - context "list_id_for" do - it "joins the host and forum name" do - Email::Sender.list_id_for("myforum", "mysite.com").should == '"myforum" ' - end - - it "removes double quotes from names" do - Email::Sender.list_id_for('Quoted "Forum"', 'quoted.com').should == '"Quoted \'Forum\'" ' - end - - it "converts the site name to lower case and removes spaces" do - Email::Sender.list_id_for("Robin's cool Forum!", "robin.com").should == '"Robin\'s cool Forum!" ' - end - end - context 'with a valid message' do let(:reply_key) { "abcd" * 8 }