Skip to content

Commit

Permalink
FIX: Use Discourse.system_user when we need a placeholder admin (#9781)
Browse files Browse the repository at this point in the history
  • Loading branch information
riking committed Jun 24, 2020
1 parent 713298c commit 52278ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
11 changes: 1 addition & 10 deletions app/models/category_featured_topic.rb
Expand Up @@ -59,7 +59,7 @@ def self.feature_topics_for(c, existing = nil)
# 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:
Expand All @@ -81,15 +81,6 @@ def self.feature_topics_for(c, existing = nil)
end
end
end

def self.fake_admin
# fake an admin
admin = User.new
admin.admin = true
admin.id = -1
admin
end

end

# == Schema Information
Expand Down
2 changes: 1 addition & 1 deletion app/services/random_topic_selector.rb
Expand Up @@ -25,7 +25,7 @@ def self.backfill(category = nil)
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)
Expand Down

0 comments on commit 52278ce

Please sign in to comment.