A platform for community discussion. Free, open, simple.
FIX: Email threads sometimes not grouping for group SMTP (#13727)
Martin Brennan068889cb5f54
diff --git a/app/jobs/regular/group_smtp_email.rb b/app/jobs/regular/group_smtp_email.rbindex ce113e5a77f..3970ecaa1fa 100644--- a/app/jobs/regular/group_smtp_email.rb+++ b/app/jobs/regular/group_smtp_email.rb@@ -52,7 +52,11 @@ module Jobs## Basically, we should never be sending this notification for the first# post in a topic.- if post.is_first_post?+ #+ # If the group does not have IMAP enabled then this could be legitimate,+ # for example in cases where we are creating a new topic to reply to another+ # group PM and we need to send the participants the group OP email.+ if post.is_first_post? && group.imap_enabledImapSyncLog.warn("Aborting SMTP email for post #{post.id} in topic #{post.topic_id} to #{email}, the post is the OP and should not send an email.", group)returnenddiff --git a/spec/jobs/regular/group_smtp_email_spec.rb b/spec/jobs/regular/group_smtp_email_spec.rbindex 9b792a84584..bc8991f0971 100644--- a/spec/jobs/regular/group_smtp_email_spec.rb+++ b/spec/jobs/regular/group_smtp_email_spec.rb@@ -171,9 +171,27 @@ RSpec.describe Jobs::GroupSmtpEmail docontext "when the post in the argument is the OP" dolet(:post_id) { post.topic.posts.first.id }- it "aborts and does not send a group SMTP email; the OP is the one that sent the email in the first place" do- expect { subject.execute(args) }.not_to(change { EmailLog.count })- expect(ActionMailer::Base.deliveries.count).to eq(0)++ context "when the group has imap enabled" do+ before do+ group.update!(imap_enabled: true)+ end++ it "aborts and does not send a group SMTP email; the OP is the one that sent the email in the first place" do+ expect { subject.execute(args) }.not_to(change { EmailLog.count })+ expect(ActionMailer::Base.deliveries.count).to eq(0)+ end+ end++ context "when the group does not have imap enabled" do+ before do+ group.update!(imap_enabled: false)+ end++ it "sends the email as expected" do+ subject.execute(args)+ expect(ActionMailer::Base.deliveries.count).to eq(1)+ endendend