mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 03:54:33 +08:00
FIX: Use original from address when forwarding to group inbox (#14114)
When emails were forwarded to a group inbox by the email address of the group, for example when an email ends up in spam and must be manually forwarded to the group+site@discoursemail.com address, the OP of the topic ended up being the group's email address instead of the sender who originally sent the email to the group inbox. This commit detects that an email has been forwarded using existing tools, and if the from address matches one of the group incoming email addresses, then we look at the forwarded email's from address and use that instead for the incoming email from address as well as the staged/regular user used for the Topic.user. This will make it much cleaner to forward emails into a group inbox, and will prevent issues with PostAlerter where the OP is double-notified for these emails.
This commit is contained in:
@ -1032,10 +1032,31 @@ describe Email::Receiver do
|
||||
end
|
||||
end
|
||||
|
||||
context "when a group forwards an email to its inbox" do
|
||||
let!(:topic) do
|
||||
group.update!(
|
||||
email_username: "team@somesmtpaddress.com",
|
||||
incoming_email: "team@somesmtpaddress.com|support+team@bar.com",
|
||||
smtp_server: "smtp.test.com",
|
||||
smtp_port: 587,
|
||||
smtp_ssl: true,
|
||||
smtp_enabled: true
|
||||
)
|
||||
process(:forwarded_by_group_to_group)
|
||||
Topic.last
|
||||
end
|
||||
|
||||
it "does not use the team's address as the from_address; it uses the original sender address" do
|
||||
expect(topic.incoming_email.first.to_addresses).to include("support+team@bar.com")
|
||||
expect(topic.incoming_email.first.from_address).to eq("fred@bedrock.com")
|
||||
end
|
||||
end
|
||||
|
||||
context "emailing a group by email_username and following reply flow" do
|
||||
let!(:original_inbound_email_topic) do
|
||||
group.update!(
|
||||
email_username: "team@somesmtpaddress.com",
|
||||
incoming_email: "team@somesmtpaddress.com|suppor+team@bar.com",
|
||||
smtp_server: "smtp.test.com",
|
||||
smtp_port: 587,
|
||||
smtp_ssl: true,
|
||||
|
Reference in New Issue
Block a user