Change all headers to X-Discourse-* instead of Discourse-*

This commit is contained in:
Robin Ward 2013-06-18 15:54:02 -04:00
parent 60fce196c7
commit 8af9952b25
6 changed files with 20 additions and 17 deletions

View file

@ -101,6 +101,9 @@ class UserNotifications < ActionMailer::Base
username = @notification.data_hash[:display_username]
notification_type = Notification.types[opts[:notification].notification_type].to_s
# For now only admins can reply by email
opts.delete(:allow_reply_by_email) unless user.admin?
email_opts = {
topic_title: @notification.data_hash[:topic_title],
message: @post.raw,

View file

@ -55,11 +55,11 @@ module Email
result['List-Unsubscribe'] = "<#{template_args[:user_preferences_url]}>" if @opts[:add_unsubscribe_link]
end
result['Discourse-Post-Id'] = @opts[:post_id].to_s if @opts[:post_id]
result['Discourse-Topic-Id'] = @opts[:topic_id].to_s if @opts[:topic_id]
result['X-Discourse-Post-Id'] = @opts[:post_id].to_s if @opts[:post_id]
result['X-Discourse-Topic-Id'] = @opts[:topic_id].to_s if @opts[:topic_id]
if allow_reply_by_email?
result['Discourse-Reply-Key'] = reply_key
result['X-Discourse-Reply-Key'] = reply_key
result['Reply-To'] = reply_by_email_address
else
result['Reply-To'] = from_value

View file

@ -47,9 +47,9 @@ module Email
user_id: @user.try(:id))
email_log.post_id = @messager
add_header_to_log('Discourse-Reply-Key', email_log, :reply_key)
add_header_to_log('Discourse-Post-Id', email_log, :post_id)
add_header_to_log('Discourse-Topic-Id', email_log, :topic_id)
add_header_to_log('X-Discourse-Reply-Key', email_log, :reply_key)
add_header_to_log('X-Discourse-Post-Id', email_log, :post_id)
add_header_to_log('X-Discourse-Topic-Id', email_log, :topic_id)
email_log.save!
email_log

View file

@ -29,8 +29,8 @@ describe Email::MessageBuilder do
context "reply by email" do
context "without allow_reply_by_email" do
it "does not have a Discourse-Reply-Key" do
expect(header_args['Discourse-Reply-Key']).to be_blank
it "does not have a X-Discourse-Reply-Key" do
expect(header_args['X-Discourse-Reply-Key']).to be_blank
end
it "returns a Reply-To header that's the same as From" do
@ -40,7 +40,7 @@ describe Email::MessageBuilder do
context "with allow_reply_by_email" do
let(:reply_by_email_builder) { Email::MessageBuilder.new(to_address, allow_reply_by_email: true) }
let(:reply_key) { reply_by_email_builder.header_args['Discourse-Reply-Key'] }
let(:reply_key) { reply_by_email_builder.header_args['X-Discourse-Reply-Key'] }
context "With the SiteSetting enabled" do
before do
@ -48,7 +48,7 @@ describe Email::MessageBuilder do
SiteSetting.stubs(:reply_by_email_address).returns("r+%{reply_key}@reply.myforum.com")
end
it "has a Discourse-Reply-Key" do
it "has a X-Discourse-Reply-Key" do
expect(reply_key).to be_present
expect(reply_key.size).to eq(32)
end
@ -63,7 +63,7 @@ describe Email::MessageBuilder do
SiteSetting.stubs(:reply_by_email_enabled?).returns(false)
end
it "has no Discourse-Reply-Key" do
it "has no X-Discourse-Reply-Key" do
expect(reply_key).to be_blank
end
@ -83,11 +83,11 @@ describe Email::MessageBuilder do
post_id: 4567) }
it "passes through a post_id" do
expect(message_with_header_args.header_args['Discourse-Post-Id']).to eq('4567')
expect(message_with_header_args.header_args['X-Discourse-Post-Id']).to eq('4567')
end
it "passes through a topic_id" do
expect(message_with_header_args.header_args['Discourse-Topic-Id']).to eq('1234')
expect(message_with_header_args.header_args['X-Discourse-Topic-Id']).to eq('1234')
end
end

View file

@ -51,8 +51,8 @@ describe Email::Sender do
context "email log with a post id and topic id" do
before do
message.header['Discourse-Post-Id'] = 3344
message.header['Discourse-Topic-Id'] = 5577
message.header['X-Discourse-Post-Id'] = 3344
message.header['X-Discourse-Topic-Id'] = 5577
end
let(:email_log) { EmailLog.last }
@ -63,7 +63,7 @@ describe Email::Sender do
context "email log with a reply key" do
before do
message.header['Discourse-Reply-Key'] = reply_key
message.header['X-Discourse-Reply-Key'] = reply_key
end
let(:email_log) { EmailLog.last }

View file

@ -2,7 +2,7 @@ require "spec_helper"
describe UserNotifications do
let(:user) { Fabricate(:user) }
let(:user) { Fabricate(:admin) }
describe ".signup" do
subject { UserNotifications.signup(user) }