FIX: Don't create staged users when processing forwarded email fails
This commit is contained in:
parent
ccc1e85bf4
commit
4a1755b780
|
@ -802,13 +802,13 @@ module Email
|
|||
|
||||
return false if email.blank? || !email["@"]
|
||||
|
||||
embedded_user = find_or_create_user(email, display_name)
|
||||
raw = try_to_encode(embedded.decoded, "UTF-8").presence || embedded.to_s
|
||||
title = embedded.subject.presence || subject
|
||||
|
||||
case destination[:type]
|
||||
when :group
|
||||
group = destination[:obj]
|
||||
embedded_user = find_or_create_user(email, display_name)
|
||||
post = create_topic(user: embedded_user,
|
||||
raw: raw,
|
||||
title: title,
|
||||
|
@ -825,6 +825,7 @@ module Email
|
|||
return false if user.staged? && !category.email_in_allow_strangers
|
||||
return false if !user.has_trust_level?(SiteSetting.email_in_min_trust)
|
||||
|
||||
embedded_user = find_or_create_user(email, display_name)
|
||||
post = create_topic(user: embedded_user,
|
||||
raw: raw,
|
||||
title: title,
|
||||
|
|
|
@ -1043,7 +1043,13 @@ describe Email::Receiver do
|
|||
staged_user_count = User.where(staged: true).count
|
||||
User.expects(:create).never
|
||||
User.expects(:create!).never
|
||||
expect { process(email_name) }.to raise_error(expected_exception)
|
||||
|
||||
if expected_exception
|
||||
expect { process(email_name) }.to raise_error(expected_exception)
|
||||
else
|
||||
process(email_name)
|
||||
end
|
||||
|
||||
expect(User.where(staged: true).count).to eq(staged_user_count)
|
||||
end
|
||||
end
|
||||
|
@ -1159,6 +1165,24 @@ describe Email::Receiver do
|
|||
context "when the email address isn't matching the one we sent the notification to" do
|
||||
include_examples "does not create staged users", :reply_user_not_matching, Email::Receiver::ReplyUserNotMatchingError
|
||||
end
|
||||
|
||||
context "when forwarded emails are enabled" do
|
||||
before do
|
||||
SiteSetting.enable_forwarded_emails = true
|
||||
end
|
||||
|
||||
context "when a reply contains a forwareded email" do
|
||||
include_examples "does not create staged users", :reply_and_forwarded
|
||||
end
|
||||
|
||||
context "forwarded email to category that doesn't allow strangers" do
|
||||
before do
|
||||
category.update!(email_in: "team@bar.com", email_in_allow_strangers: false)
|
||||
end
|
||||
|
||||
include_examples "cleans up staged users", :forwarded_email_1, Email::Receiver::StrangersNotAllowedError
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "replying without key is allowed" do
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
Message-ID: <58@foo.bar.mail>
|
||||
From: Ba Bar <discourse@bar.com>
|
||||
To: reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com
|
||||
Date: Mon, 1 Dec 2016 13:37:42 +0100
|
||||
Subject: FW: Discoursing much?
|
||||
|
||||
@team, can you have a look at this email below?
|
||||
|
||||
From: Some One <some@one.com>
|
||||
To: Ba Bar <discourse@bar.com>
|
||||
Date: Mon, 1 Dec 2016 00:13:37 +0100
|
||||
Subject: Discoursing much?
|
||||
|
||||
Hello Ba Bar,
|
||||
|
||||
Discoursing much today?
|
||||
|
||||
XoXo
|
Loading…
Reference in New Issue