diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 35f73888d9e..4cfa9e6e047 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -36,20 +36,14 @@ class SiteController < ApplicationController header_primary_color: ColorScheme.hex_for_name("header_primary") || "333333", header_background_color: ColorScheme.hex_for_name("header_background") || "ffffff", login_required: SiteSetting.login_required, + locale: SiteSetting.default_locale, + include_in_discourse_discover: SiteSetting.include_in_discourse_discover, } if mobile_logo_url = SiteSetting.site_mobile_logo_url.presence results[:mobile_logo_url] = UrlHelper.absolute(mobile_logo_url) end - if guardian.is_discourse_hub_request? - DiscourseHub.stats_fetched_at = Time.zone.now - discover_data = About.discourse_discover - discover_data.each_key do |key| - results["discourse_discover_#{key}".to_sym] = discover_data[key] - end - end - # this info is always available cause it can be scraped from a 404 page render json: results end diff --git a/app/models/about.rb b/app/models/about.rb index eb1b0aff719..c92b5f747e2 100644 --- a/app/models/about.rb +++ b/app/models/about.rb @@ -98,12 +98,4 @@ class About def category_mods_limit=(number) @category_mods_limit = number end - - def self.discourse_discover - @discourse_discover ||= { - enrolled: SiteSetting.include_in_discourse_discover?, - logo_url: UrlHelper.absolute(SiteSetting.site_logo_url), - locale: SiteSetting.default_locale, - } - end end diff --git a/lib/guardian.rb b/lib/guardian.rb index 478eb918f4b..63846a7a742 100644 --- a/lib/guardian.rb +++ b/lib/guardian.rb @@ -636,10 +636,6 @@ class Guardian other && authenticated? && other.is_a?(User) && @user == other end - def is_discourse_hub_request? - request&.user_agent == "Discourse Hub" - end - private def is_my_own?(obj) diff --git a/spec/requests/api/schemas/json/site_basic_info_response.json b/spec/requests/api/schemas/json/site_basic_info_response.json index 4363bb50f9d..77a85af559a 100644 --- a/spec/requests/api/schemas/json/site_basic_info_response.json +++ b/spec/requests/api/schemas/json/site_basic_info_response.json @@ -28,6 +28,12 @@ "login_required": { "type": "boolean" }, + "locale": { + "type": "string" + }, + "include_in_discourse_discover": { + "type": "boolean" + }, "mobile_logo_url": { "type": "string" } @@ -42,6 +48,8 @@ "header_primary_color", "header_background_color", "login_required", + "locale", + "include_in_discourse_discover", "mobile_logo_url" ] } \ No newline at end of file diff --git a/spec/requests/site_controller_spec.rb b/spec/requests/site_controller_spec.rb index 9a2db4a0a43..29ffe94c2e3 100644 --- a/spec/requests/site_controller_spec.rb +++ b/spec/requests/site_controller_spec.rb @@ -15,7 +15,7 @@ RSpec.describe SiteController do SiteSetting.include_in_discourse_discover = true Theme.clear_default! - get "/site/basic-info.json", headers: { "HTTP_USER_AGENT" => "Discourse Hub" } + get "/site/basic-info.json" json = response.parsed_body expected_url = UrlHelper.absolute(upload.url) @@ -29,16 +29,19 @@ RSpec.describe SiteController do expect(json["header_primary_color"]).to eq("333333") expect(json["header_background_color"]).to eq("ffffff") expect(json["login_required"]).to eq(true) - expect(json["discourse_discover_enrolled"]).to eq(true) + expect(json["locale"]).to eq("en") + expect(json["include_in_discourse_discover"]).to eq(true) end - it "skips `discourse_discover_enrolled` if `include_in_discourse_discover` setting disabled" do + it "includes false values for include_in_discourse_discover and login_required" do SiteSetting.include_in_discourse_discover = false + SiteSetting.login_required = false get "/site/basic-info.json" json = response.parsed_body - expect(json.keys).not_to include("discourse_discover_enrolled") + expect(json["include_in_discourse_discover"]).to eq(false) + expect(json["login_required"]).to eq(false) end end