some email notification header fixes

This commit is contained in:
Jeff Atwood 2014-06-13 15:42:14 -07:00
parent c690fa0d19
commit beaa145572
2 changed files with 10 additions and 25 deletions

View File

@ -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 = "<topic/#{topic_id}@#{host}>"
@message.header['In-Reply-To'] = topic_identitfier
@message.header['References'] = topic_identitfier
topic_identifier = "<topic/#{topic_id}@#{host}>"
@message.header['In-Reply-To'] = topic_identifier
@message.header['References'] = topic_identifier
# http://www.ietf.org/rfc/rfc2919.txt
@message.header['List-ID'] = "<topic.#{topic_id}.#{host}>"
# 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(/\"/, "'")}\" <discourse.forum.#{Slug.for(site_name)}.#{host}>"
end
private
def header_value(name)

View File

@ -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" <discourse.forum.myforum.mysite.com>'
end
it "removes double quotes from names" do
Email::Sender.list_id_for('Quoted "Forum"', 'quoted.com').should == '"Quoted \'Forum\'" <discourse.forum.quoted-forum.quoted.com>'
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!" <discourse.forum.robins-cool-forum.robin.com>'
end
end
context 'with a valid message' do
let(:reply_key) { "abcd" * 8 }