From 9954a677ab46041cc42e2b588c35ff6744cddd2d Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Thu, 3 Sep 2020 08:58:25 +1000 Subject: [PATCH] FIX: don't send mailing list for post with empty content (#10577) discourse-assign is creating posts with empty content to show that a specific user was assign/unassigned for a specific topic. It is causing confusing emails with empty content The bug was mentioned here: https://meta.discourse.org/t/again-on-empty-emails-and-notifications-generated-on-topic-assignment/162213 --- app/jobs/regular/notify_mailing_list_subscribers.rb | 2 +- spec/jobs/notify_mailing_list_subscribers_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/jobs/regular/notify_mailing_list_subscribers.rb b/app/jobs/regular/notify_mailing_list_subscribers.rb index 66a86c89ff..7cf01bf5d4 100644 --- a/app/jobs/regular/notify_mailing_list_subscribers.rb +++ b/app/jobs/regular/notify_mailing_list_subscribers.rb @@ -26,7 +26,7 @@ module Jobs post_id = args[:post_id] post = post_id ? Post.with_deleted.find_by(id: post_id) : nil - return if !post || post.trashed? || post.user_deleted? || !post.topic + return if !post || post.trashed? || post.user_deleted? || !post.topic || post.raw.blank? users = User.activated.not_silenced.not_suspended.real diff --git a/spec/jobs/notify_mailing_list_subscribers_spec.rb b/spec/jobs/notify_mailing_list_subscribers_spec.rb index 8d2d7133f2..8b09123a44 100644 --- a/spec/jobs/notify_mailing_list_subscribers_spec.rb +++ b/spec/jobs/notify_mailing_list_subscribers_spec.rb @@ -65,6 +65,11 @@ describe Jobs::NotifyMailingListSubscribers do include_examples "no emails" end + context "with a empty post" do + before { post.update_columns(raw: "") } + include_examples "no emails" + end + context "with a user_deleted post" do before { post.update(user_deleted: true) } include_examples "no emails"