A platform for community discussion. Free, open, simple.
FIX: Don't notify of pending flags if min_flags_staff_visibility not met
Robin Wardf32de88dfcd1
diff --git a/app/jobs/scheduled/pending_flags_reminder.rb b/app/jobs/scheduled/pending_flags_reminder.rbindex 05ab123ad87..50f02a5cac3 100644--- a/app/jobs/scheduled/pending_flags_reminder.rb+++ b/app/jobs/scheduled/pending_flags_reminder.rb@@ -15,7 +15,7 @@ module Jobsflag_ids = pending_flag_ids- if flag_ids.size > 0 && last_notified_id.to_i < flag_ids.max+ if flag_ids.size >= SiteSetting.min_flags_staff_visibility && last_notified_id.to_i < flag_ids.maxusernames = active_moderator_usernamesmentions = usernames.size > 0 ? "@#{usernames.join(', @')} " : ""diff --git a/spec/jobs/pending_flags_reminder_spec.rb b/spec/jobs/pending_flags_reminder_spec.rbindex a99852b02f2..6a69defe4ed 100644--- a/spec/jobs/pending_flags_reminder_spec.rb+++ b/spec/jobs/pending_flags_reminder_spec.rb@@ -28,13 +28,6 @@ describe Jobs::PendingFlagsReminder dodescribed_class.new.execute({})end- it "sends message when there is a flag older than 48 hours" do- Fabricate(:flag, created_at: 49.hours.ago)- PostAction.stubs(:flagged_posts_count).returns(1)- PostCreator.expects(:create).once.returns(true)- described_class.new.execute({})- end-it "doesn't send a message if there are no new flags older than 48 hours old" doold_flag = Fabricate(:flag, created_at: 50.hours.ago)new_flag = Fabricate(:flag, created_at: 47.hours.ago)@@ -45,5 +38,21 @@ describe Jobs::PendingFlagsReminder dojob.execute({})expect(job.last_notified_id).to eq(old_flag.id)end++ it "doesn't send a message when min_flags_staff_visibility is not met" do+ SiteSetting.min_flags_staff_visibility = 2+ Fabricate(:flag, created_at: 49.hours.ago)+ PostAction.stubs(:flagged_posts_count).returns(1)+ PostCreator.expects(:create).never+ described_class.new.execute({})+ end++ it "sends message when there is a flag older than 48 hours" do+ Fabricate(:flag, created_at: 49.hours.ago)+ PostAction.stubs(:flagged_posts_count).returns(1)+ PostCreator.expects(:create).once.returns(true)+ described_class.new.execute({})+ end+endend