mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 14:53:37 +08:00
30d5e752d7
I took the wrong approach here, need to rethink. * Revert "FIX: Use Guardian.basic_user instead of new (anon) (#24705)" This reverts commit9057272ee2
. * Revert "DEV: Remove unnecessary method_missing from GuardianUser (#24735)" This reverts commita5d4bf6dd2
. * Revert "DEV: Improve Guardian devex (#24706)" This reverts commit77b6a038ba
. * Revert "FIX: Introduce Guardian::BasicUser for oneboxing checks (#24681)" This reverts commitde983796e1
.
31 lines
1.0 KiB
Ruby
31 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class AboutController < ApplicationController
|
|
requires_login only: [:live_post_counts]
|
|
|
|
skip_before_action :check_xhr, only: [:index]
|
|
|
|
def index
|
|
return redirect_to path("/login") if SiteSetting.login_required? && current_user.nil?
|
|
|
|
@about = About.new(current_user)
|
|
@title = "#{I18n.t("js.about.simple_title")} - #{SiteSetting.title}"
|
|
respond_to do |format|
|
|
format.html { render :index }
|
|
format.json { render_json_dump(AboutSerializer.new(@about, scope: guardian)) }
|
|
end
|
|
end
|
|
|
|
def live_post_counts
|
|
unless current_user.staff?
|
|
RateLimiter.new(current_user, "live_post_counts", 1, 10.minutes).performed!
|
|
end
|
|
category_topic_ids = Category.select(:topic_id).where.not(topic_id: nil)
|
|
public_topics =
|
|
Topic.listable_topics.visible.secured(Guardian.new(nil)).where.not(id: category_topic_ids)
|
|
stats = { public_topic_count: public_topics.count }
|
|
stats[:public_post_count] = public_topics.sum(:posts_count) - stats[:public_topic_count]
|
|
render json: stats
|
|
end
|
|
end
|