From dd83a0755004cce30f5a15b7ad79680986a0dbe8 Mon Sep 17 00:00:00 2001 From: Rafael dos Santos Silva Date: Fri, 5 Apr 2024 12:12:59 -0300 Subject: [PATCH] FEATURE: Hide summarization in PMs (#26532) --- lib/summarization/base.rb | 1 + spec/lib/summarization/base_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/summarization/base.rb b/lib/summarization/base.rb index 32d6c7a41f8..9c22d336c7e 100644 --- a/lib/summarization/base.rb +++ b/lib/summarization/base.rb @@ -24,6 +24,7 @@ module Summarization def can_see_summary?(target, user) return false if SiteSetting.summarization_strategy.blank? + return false if target.class == Topic && target.private_message? has_cached_summary = SummarySection.exists?(target: target, meta_section_id: nil) return has_cached_summary if user.nil? diff --git a/spec/lib/summarization/base_spec.rb b/spec/lib/summarization/base_spec.rb index d170f1ede50..2ecf8f43970 100644 --- a/spec/lib/summarization/base_spec.rb +++ b/spec/lib/summarization/base_spec.rb @@ -65,5 +65,14 @@ describe Summarization::Base do expect(described_class.can_see_summary?(topic, nil)).to eq(true) end end + + context "when the topic is a PM" do + before { SiteSetting.custom_summarization_allowed_groups = group.id } + let(:pm) { Fabricate(:private_message_topic) } + + it "returns false" do + expect(described_class.can_see_summary?(pm, user)).to eq(false) + end + end end end