FIX: Use Discourse.system_user when we need a placeholder admin (#9781)

This commit is contained in:
Kane York 2020-06-23 22:51:30 -07:00 committed by GitHub
parent 713298c622
commit 52278ce6fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 11 deletions

View File

@ -59,7 +59,7 @@ class CategoryFeaturedTopic < ActiveRecord::Base
# no featured topics (all the previous 2x topics are only visible to admins)
# Add topics, even if they're in secured categories or invisible
query = TopicQuery.new(CategoryFeaturedTopic.fake_admin, query_opts)
query = TopicQuery.new(Discourse.system_user, query_opts)
results = query.list_category_topic_ids(c).uniq
# Add some topics that are visible to everyone:
@ -81,15 +81,6 @@ class CategoryFeaturedTopic < ActiveRecord::Base
end
end
end
def self.fake_admin
# fake an admin
admin = User.new
admin.admin = true
admin.id = -1
admin
end
end
# == Schema Information

View File

@ -25,7 +25,7 @@ class RandomTopicSelector
end
# don't leak private categories into the "everything" group
options[:guardian] = Guardian.new(CategoryFeaturedTopic.fake_admin)
options[:guardian] = Guardian.new(Discourse.system_user)
end
query = TopicQuery.new(nil, options)