From ba0105f286d3147282798e5457da67a89e8fc5fd Mon Sep 17 00:00:00 2001 From: TripleU <182648541+TripleU613@users.noreply.github.com> Date: Thu, 19 Nov 2026 18:38:44 -0500 Subject: [PATCH] Whispers: a client's whisper flag counts only while whispers are on Follow-up to #386. With mod_whisper_enabled or jtech_enabled off, a member could still send mod_whisper=true on a post that answers no whisper. Creation ignored it and the post came out public, but its copy in the approval queue kept the flag, so it was hidden from non-staff reviewers and kept out of the reports chat. The queue marker now follows the same rule as creation: the client's flag needs the switch on; answering an existing whisper still marks the post whatever the switch says. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01H3rUWsMdwFCAp9g5VhRD7d --- spec/requests/whisper_leak_matrix_spec.rb | 35 +++++++++++++++++++++++ sub_plugins/mod_categories.rb | 10 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/spec/requests/whisper_leak_matrix_spec.rb b/spec/requests/whisper_leak_matrix_spec.rb index a8bbaeaf..ae165900 100644 --- a/spec/requests/whisper_leak_matrix_spec.rb +++ b/spec/requests/whisper_leak_matrix_spec.rb @@ -460,6 +460,41 @@ def stream_ids(user) ).perform expect(Reviewable.viewable_by(stranger).to_a.map(&:id)).to include(plain.reviewable.id) end + + it "ignores a client's whisper flag while whispers are switched off" do + SiteSetting.enable_category_group_moderation = true + reviewers = Fabricate(:group) + reviewers.add(stranger) + Fabricate(:category_moderation_group, category: category, group: reviewers) + SiteSetting.mod_whisper_enabled = false + + result = + NewPostManager.new( + alice, + :topic_id => topic.id, + :raw => "a public reply that claims to be a whisper", + armed => "true", + ).perform + expect(result.action).to eq(:enqueued) + + reviewable = result.reviewable + expect(reviewable.payload).not_to have_key(armed) + expect(DiscourseModCategories::Whisper.private_reviewable?(reviewable)).to eq(false) + expect(Reviewable.viewable_by(stranger).to_a.map(&:id)).to include(reviewable.id) + + reviewable.perform(admin, :approve_post) + expect(whisper?(reviewable.reload.target)).to eq(false) + + # Answering an existing whisper still keeps the answer private. + back = + NewPostManager.new( + alice, + topic_id: topic.id, + raw: "queued whisper-back with the switch off", + reply_to_post_number: whisper_to_alice.post_number, + ).perform + expect(DiscourseModCategories::Whisper.private_reviewable?(back.reviewable)).to eq(true) + end end describe "the Telegram bridge" do diff --git a/sub_plugins/mod_categories.rb b/sub_plugins/mod_categories.rb index c9a9b4be..b4bd121a 100644 --- a/sub_plugins/mod_categories.rb +++ b/sub_plugins/mod_categories.rb @@ -659,10 +659,18 @@ class Engine < ::Rails::Engine args[:raw], ) armed_key = DiscourseModCategories::POST_WHISPER_ARMED_PARAM + # The client's own flag only counts while whispers can be written, as in + # Whisper.prepare_new_post!. With them off it would still have marked the + # queued copy a whisper, hiding a post that comes out public from + # reviewers and from the reports chat. armed = - ::ActiveModel::Type::Boolean.new.cast(DiscourseModCategories::Whisper.opt(args, armed_key)) + DiscourseModCategories::Whisper.enabled? && + ::ActiveModel::Type::Boolean.new.cast(DiscourseModCategories::Whisper.opt(args, armed_key)) if armed || DiscourseModCategories::Whisper.answered_whispers(stub, {}, user).any? args[armed_key] = "true" + else + args.delete(armed_key) + args.delete(armed_key.to_sym) end nil rescue StandardError => e