FIX: Ensure MessageIdService can handle hostname changes and multisite (#15231)
This commit is contained in:
parent
74387e83b6
commit
f799b8bfb1
|
@ -80,11 +80,11 @@ module Email
|
|||
end
|
||||
|
||||
def message_id_post_id_regexp
|
||||
@message_id_post_id_regexp ||= Regexp.new "topic/\\d+/(\\d+|\\d+\.\\w+)@#{Regexp.escape(host)}"
|
||||
Regexp.new "topic/\\d+/(\\d+|\\d+\.\\w+)@#{Regexp.escape(host)}"
|
||||
end
|
||||
|
||||
def message_id_topic_id_regexp
|
||||
@message_id_topic_id_regexp ||= Regexp.new "topic/(\\d+|\\d+\.\\w+)@#{Regexp.escape(host)}"
|
||||
Regexp.new "topic/(\\d+|\\d+\.\\w+)@#{Regexp.escape(host)}"
|
||||
end
|
||||
|
||||
def message_id_rfc_format(message_id)
|
||||
|
@ -100,7 +100,7 @@ module Email
|
|||
end
|
||||
|
||||
def host
|
||||
@host ||= Email::Sender.host_for(Discourse.base_url)
|
||||
Email::Sender.host_for(Discourse.base_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -120,4 +120,12 @@ describe Email::MessageIdService do
|
|||
expect(Email::MessageIdService.message_id_clean(message_id)).to eq(message_id)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#host" do
|
||||
it "handles hostname changes at runtime" do
|
||||
expect(Email::MessageIdService.host).to eq("test.localhost")
|
||||
SiteSetting.force_hostname = "other.domain.example.com"
|
||||
expect(Email::MessageIdService.host).to eq("other.domain.example.com")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue