From fa9e708cb7abd8282554dd982fdc7a1171031939 Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Mon, 31 Oct 2022 01:26:20 +0300 Subject: [PATCH] FIX: Don't notify topic author about small action posts (#18789) --- app/services/post_alerter.rb | 4 ++-- spec/services/post_alerter_spec.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb index edd0deb69bd..8c31d579ce2 100644 --- a/app/services/post_alerter.rb +++ b/app/services/post_alerter.rb @@ -146,8 +146,8 @@ class PostAlerter # replies reply_to_user = post.reply_notification_target - if new_record - if reply_to_user && !notified.include?(reply_to_user) && notify_about_reply?(post) + if new_record && notify_about_reply?(post) + if reply_to_user && !notified.include?(reply_to_user) notified += notify_non_pm_users(reply_to_user, :replied, post) end diff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rb index 4dac502dd8e..8f2b5e68302 100644 --- a/spec/services/post_alerter_spec.rb +++ b/spec/services/post_alerter_spec.rb @@ -1343,6 +1343,21 @@ RSpec.describe PostAlerter do read: false )).to eq(true) end + + it "it doesn't notify about small action posts when the topic author is watching the topic " do + Jobs.run_immediately! + + u1 = Fabricate(:admin) + u2 = Fabricate(:admin) + + topic = create_topic(user: u1) + + u1.notifications.destroy_all + + expect do + topic.update_status("closed", true, u2, message: "hello world") + end.not_to change { u1.reload.notifications.count } + end end context "with category" do