A platform for community discussion. Free, open, simple.
FIX: Don't show suggested messages if private messages are disabled
Robin Ward17ebfd17158d
diff --git a/lib/topic_query.rb b/lib/topic_query.rbindex 2d27044739b..1556e085fc6 100644--- a/lib/topic_query.rb+++ b/lib/topic_query.rb@@ -100,7 +100,11 @@ class TopicQuery# Return a list of suggested topics for a topicdef list_suggested_for(topic)- return if topic.private_message? && !@user++ # Don't suggest messages unless we have a user, and private messages are+ # enabled.+ return if topic.private_message? &&+ (@user.blank? || !SiteSetting.enable_private_messages?)builder = SuggestedTopicsBuilder.new(topic)diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rbindex be119f53099..4ca84492b35 100644--- a/spec/components/topic_query_spec.rb+++ b/spec/components/topic_query_spec.rb@@ -695,6 +695,10 @@ describe TopicQuery doexpect(TopicQuery.new(user).list_suggested_for(pm_to_user).topics.map(&:id)).to(eq([new_pm.id, unread_pm.id, related_by_user_pm.id]))++ SiteSetting.enable_private_messages = false+ expect(TopicQuery.new(user).list_suggested_for(pm_to_group)).to be_blank+ expect(TopicQuery.new(user).list_suggested_for(pm_to_user)).to be_blankendend