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

We already do this for new and unread results, but not for randomly suggested topics.
This commit is contained in:
Roman Rizzi 2020-11-24 09:16:10 -03:00 committed by GitHub
parent 123107c28f
commit 7ad2c2bdd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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