FEATURE: Hide summarization in PMs (#26532)

This commit is contained in:
Rafael dos Santos Silva 2024-04-05 12:12:59 -03:00 committed by GitHub
parent 552203aa1d
commit dd83a07550
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,7 @@ module Summarization
def can_see_summary?(target, user) def can_see_summary?(target, user)
return false if SiteSetting.summarization_strategy.blank? 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) has_cached_summary = SummarySection.exists?(target: target, meta_section_id: nil)
return has_cached_summary if user.nil? return has_cached_summary if user.nil?

View File

@ -65,5 +65,14 @@ describe Summarization::Base do
expect(described_class.can_see_summary?(topic, nil)).to eq(true) expect(described_class.can_see_summary?(topic, nil)).to eq(true)
end end
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
end end