Skip to content

A platform for community discussion. Free, open, simple.

FIX: Exclude muted results when suggested related topics at random. (#11290)

Roman Rizzi7ad2c2bdd8d4
diff --git a/lib/topic_query.rb b/lib/topic_query.rb
index 2d4041843b3..7070263e6fd 100644
--- a/lib/topic_query.rb
+++ b/lib/topic_query.rb
@@ -1085,6 +1085,7 @@ class TopicQuery
result = result.where("topics.id NOT IN (?)", excluded_topic_ids) unless excluded_topic_ids.empty?
result = remove_muted_categories(result, @user)
+ result = remove_muted_topics(result, @user)
# If we are in a category, prefer it for the random results
if topic.category_id
diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb
index 802840cb391..f4f13b6a888 100644
--- a/spec/components/topic_query_spec.rb
+++ b/spec/components/topic_query_spec.rb
@@ -967,6 +967,18 @@ describe TopicQuery do
expect(topic_query.list_suggested_for(tt).topics.length).to eq(1)
end
+ it 'removes muted topics' do
+ SiteSetting.suggested_topics_max_days_old = 1365
+ tt = topic
+ TopicNotifier.new(old_topic).mute!(user)
+ clear_cache!
+
+ topics = topic_query.list_suggested_for(tt).topics
+
+ expect(topics.length).to eq(1)
+ expect(topics).not_to include(old_topic)
+ end
+
end
context 'with private messages' do