mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 23:38:09 +08:00
some email notification header fixes
This commit is contained in:
@ -58,8 +58,6 @@ module Email
|
|||||||
|
|
||||||
host = Email::Sender.host_for(Discourse.base_url)
|
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')
|
topic_id = header_value('X-Discourse-Topic-Id')
|
||||||
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')
|
||||||
@ -67,9 +65,16 @@ module Email
|
|||||||
if topic_id.present?
|
if topic_id.present?
|
||||||
email_log.topic_id = topic_id
|
email_log.topic_id = topic_id
|
||||||
|
|
||||||
topic_identitfier = "<topic/#{topic_id}@#{host}>"
|
topic_identifier = "<topic/#{topic_id}@#{host}>"
|
||||||
@message.header['In-Reply-To'] = topic_identitfier
|
@message.header['In-Reply-To'] = topic_identifier
|
||||||
@message.header['References'] = topic_identitfier
|
@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
|
end
|
||||||
|
|
||||||
email_log.post_id = post_id if post_id.present?
|
email_log.post_id = post_id if post_id.present?
|
||||||
@ -110,12 +115,6 @@ module Email
|
|||||||
host
|
host
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.list_id_for(site_name, host)
|
|
||||||
"\"#{site_name.gsub(/\"/, "'")}\" <discourse.forum.#{Slug.for(site_name)}.#{host}>"
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def header_value(name)
|
def header_value(name)
|
||||||
|
@ -39,20 +39,6 @@ describe Email::Sender do
|
|||||||
|
|
||||||
end
|
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
|
context 'with a valid message' do
|
||||||
|
|
||||||
let(:reply_key) { "abcd" * 8 }
|
let(:reply_key) { "abcd" * 8 }
|
||||||
|
Reference in New Issue
Block a user