From 1bd9ca11e777f880462ae64c6795ef7de28a8cd2 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Sun, 25 Feb 2024 10:42:50 +0530 Subject: [PATCH] DEV: include more data in Discourse Discover enrollment payload. (#25846) Adding forum's URL, title, and locale to the payload of enrollment can be helpful while managing it in the Discourse Discover. --- lib/discourse_hub.rb | 7 ++++++- spec/lib/discourse_hub_spec.rb | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/discourse_hub.rb b/lib/discourse_hub.rb index 34994430fbb..cdab5efeda3 100644 --- a/lib/discourse_hub.rb +++ b/lib/discourse_hub.rb @@ -15,7 +15,12 @@ module DiscourseHub end def self.discover_enrollment_payload - { include_in_discourse_discover: SiteSetting.include_in_discourse_discover? } + { + include_in_discourse_discover: SiteSetting.include_in_discourse_discover?, + forum_url: Discourse.base_url, + forum_title: SiteSetting.title, + locale: I18n.locale, + } end def self.discover_enrollment diff --git a/spec/lib/discourse_hub_spec.rb b/spec/lib/discourse_hub_spec.rb index 3b7b4ea3d68..16bdf27897e 100644 --- a/spec/lib/discourse_hub_spec.rb +++ b/spec/lib/discourse_hub_spec.rb @@ -33,6 +33,15 @@ RSpec.describe DiscourseHub do end end + describe ".discover_enrollment_payload" do + it "should return the correct payload" do + payload = DiscourseHub.discover_enrollment_payload + expect(payload[:forum_url]).to eq(Discourse.base_url) + expect(payload[:forum_title]).to eq(SiteSetting.title) + expect(payload[:locale]).to eq(I18n.locale) + end + end + describe ".version_check_payload" do describe "when Discourse Hub has not fetched stats since past 7 days" do it "should include stats" do