mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 03:18:09 +08:00
FIX: IMAP allow unknown senders to reply to group topics via email (#11877)
Adds a new column/setting to groups, allow_unknown_sender_topic_replies, which is default false. When enabled, this scenario is allowed via IMAP: * OP sends an email to the support email address which is synced to a group inbox via IMAP, creating a group topic * Group user replies to the group topic * An email notification is sent to the OP of the topic via GroupSMTPMailer * The OP has several email accounts and the reply is sent to all of them, or they forward their reply to another email account * The OP replies from a different email address than the OP (gloria@gmail.com instead of gloria@hey.com for example) * The a new staged user is created, the new reply is accepted and added to the topic, and the staged user is added to the topic allowed users Without allow_unknown_sender_topic_replies enabled the new reply creates an entirely new topic (because the email address it is sent from is not previously part of the topic email chain).
This commit is contained in:
@ -951,8 +951,9 @@ describe Email::Receiver do
|
||||
expect { process(:email_reply_2) }.to change { topic.posts.count }.by(1).and change { Topic.count }.by(0)
|
||||
end
|
||||
|
||||
it "creates a new topic when the sender is not known" do
|
||||
it "creates a new topic when the sender is not known and the group does not allow unknown senders to reply to topics" do
|
||||
IncomingEmail.where(message_id: '34@foo.bar.mail').update(cc_addresses: 'three@foo.com')
|
||||
group.update(allow_unknown_sender_topic_replies: false)
|
||||
expect { process(:email_reply_2) }.to change { topic.posts.count }.by(0).and change { Topic.count }.by(1)
|
||||
end
|
||||
|
||||
@ -960,6 +961,25 @@ describe Email::Receiver do
|
||||
IncomingEmail.where(message_id: '34@foo.bar.mail').update(message_id: '99@foo.bar.mail')
|
||||
expect { process(:email_reply_2) }.to change { topic.posts.count }.by(0).and change { Topic.count }.by(1)
|
||||
end
|
||||
|
||||
it "includes the sender on the topic when the message id is known, the sender is not known, and the group allows unknown senders to reply to topics" do
|
||||
IncomingEmail.where(message_id: '34@foo.bar.mail').update(cc_addresses: 'three@foo.com')
|
||||
group.update(allow_unknown_sender_topic_replies: true)
|
||||
expect { process(:email_reply_2) }.to change { topic.posts.count }.by(1).and change { Topic.count }.by(0)
|
||||
end
|
||||
|
||||
context "when the sender is not in the topic allowed users" do
|
||||
before do
|
||||
user = User.find_by_email("two@foo.com")
|
||||
topic.topic_allowed_users.find_by(user: user).destroy
|
||||
end
|
||||
|
||||
it "adds them to the topic at the same time" do
|
||||
IncomingEmail.where(message_id: '34@foo.bar.mail').update(cc_addresses: 'three@foo.com')
|
||||
group.update(allow_unknown_sender_topic_replies: true)
|
||||
expect { process(:email_reply_2) }.to change { topic.posts.count }.by(1).and change { Topic.count }.by(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user