handle emails with localized headers 😠
This commit is contained in:
parent
6b4f265a8c
commit
185dcb2ca1
|
@ -239,6 +239,8 @@ module Email
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_from_field(mail)
|
def parse_from_field(mail)
|
||||||
|
return unless mail[:from]
|
||||||
|
|
||||||
if mail[:from].errors.blank?
|
if mail[:from].errors.blank?
|
||||||
mail[:from].address_list.addresses.each do |address_field|
|
mail[:from].address_list.addresses.each do |address_field|
|
||||||
address_field.decoded
|
address_field.decoded
|
||||||
|
|
|
@ -383,37 +383,46 @@ describe Email::Receiver do
|
||||||
expect(Post.last.raw).to match(/discourse\.rb/)
|
expect(Post.last.raw).to match(/discourse\.rb/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handles forwarded emails" do
|
context "with forwarded emails enabled" do
|
||||||
SiteSetting.enable_forwarded_emails = true
|
before { SiteSetting.enable_forwarded_emails = true }
|
||||||
expect { process(:forwarded_email_1) }.to change(Topic, :count)
|
|
||||||
|
|
||||||
forwarded_post, last_post = *Post.last(2)
|
it "handles forwarded emails" do
|
||||||
|
expect { process(:forwarded_email_1) }.to change(Topic, :count)
|
||||||
|
|
||||||
expect(forwarded_post.user.email).to eq("some@one.com")
|
forwarded_post, last_post = *Post.last(2)
|
||||||
expect(last_post.user.email).to eq("ba@bar.com")
|
|
||||||
|
|
||||||
expect(forwarded_post.raw).to match(/XoXo/)
|
expect(forwarded_post.user.email).to eq("some@one.com")
|
||||||
expect(last_post.raw).to match(/can you have a look at this email below/)
|
expect(last_post.user.email).to eq("ba@bar.com")
|
||||||
|
|
||||||
expect(last_post.post_type).to eq(Post.types[:regular])
|
expect(forwarded_post.raw).to match(/XoXo/)
|
||||||
end
|
expect(last_post.raw).to match(/can you have a look at this email below/)
|
||||||
|
|
||||||
it "handles weirdly forwarded emails" do
|
expect(last_post.post_type).to eq(Post.types[:regular])
|
||||||
group.add(Fabricate(:user, email: "ba@bar.com"))
|
end
|
||||||
group.save
|
|
||||||
|
|
||||||
SiteSetting.enable_forwarded_emails = true
|
it "handles weirdly forwarded emails" do
|
||||||
expect { process(:forwarded_email_2) }.to change(Topic, :count)
|
group.add(Fabricate(:user, email: "ba@bar.com"))
|
||||||
|
group.save
|
||||||
|
|
||||||
forwarded_post, last_post = *Post.last(2)
|
SiteSetting.enable_forwarded_emails = true
|
||||||
|
expect { process(:forwarded_email_2) }.to change(Topic, :count)
|
||||||
|
|
||||||
expect(forwarded_post.user.email).to eq("some@one.com")
|
forwarded_post, last_post = *Post.last(2)
|
||||||
expect(last_post.user.email).to eq("ba@bar.com")
|
|
||||||
|
|
||||||
expect(forwarded_post.raw).to match(/XoXo/)
|
expect(forwarded_post.user.email).to eq("some@one.com")
|
||||||
expect(last_post.raw).to match(/can you have a look at this email below/)
|
expect(last_post.user.email).to eq("ba@bar.com")
|
||||||
|
|
||||||
|
expect(forwarded_post.raw).to match(/XoXo/)
|
||||||
|
expect(last_post.raw).to match(/can you have a look at this email below/)
|
||||||
|
|
||||||
|
expect(last_post.post_type).to eq(Post.types[:whisper])
|
||||||
|
end
|
||||||
|
|
||||||
|
# Who thought this was a good idea?!
|
||||||
|
it "doesn't blow up with localized email headers" do
|
||||||
|
expect { process(:forwarded_email_3) }.to change(Topic, :count)
|
||||||
|
end
|
||||||
|
|
||||||
expect(last_post.post_type).to eq(Post.types[:whisper])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue