FEATURE: Allow TL4 users to see unlisted topics (#19890)

TL4 users can already list and unlist topics, but they can't see
the unlisted topics. This change brings this to par by allowing
TL4 users to also see unlisted topics.
This commit is contained in:
Ted Johansson
2023-01-17 16:50:15 +08:00
committed by GitHub
parent 341f93e0ba
commit 9cdeb93375
5 changed files with 34 additions and 8 deletions

View File

@@ -642,9 +642,13 @@ class TopicQuery
options.reverse_merge!(@options)
options.reverse_merge!(per_page: per_page_setting) unless options[:limit] == false
# Whether to return visible topics
options[:visible] = true if @user.nil? || @user.regular?
options[:visible] = false if @user && @user.id == options[:filtered_to_user]
# Whether to include unlisted (visible = false) topics
viewing_own_topics = @user && @user.id == options[:filtered_to_user]
if options[:visible].nil?
options[:visible] = true if @user.nil? || @user.regular?
options[:visible] = false if @guardian.can_see_unlisted_topics? || viewing_own_topics
end
# Start with a list of all topics
result = Topic.unscoped.includes(:category)