discourse/config/initializers/100-onebox_options.rb
Vinoth Kannan d681decf01
FEATURE: use new site setting for onebox custom user agent. (#28045)
Previously, we couldn't change the user agent name dynamically for onebox requests. In this commit, a new hidden site setting `onebox_user_agent` is created to override the default user agent value specified in the [initializer](c333e9d6e6/config/initializers/100-onebox_options.rb (L15)).

Co-authored-by: Régis Hanol <regis@hanol.fr>
2024-07-24 04:45:30 +05:30

19 lines
463 B
Ruby

# frozen_string_literal: true
Rails.application.config.to_prepare do
if Rails.env.development? && SiteSetting.port.to_i > 0
Onebox.options = {
twitter_client: TwitterApi,
redirect_limit: 3,
user_agent: "Discourse Forum Onebox",
allowed_ports: [80, 443, SiteSetting.port.to_i],
}
else
Onebox.options = {
twitter_client: TwitterApi,
redirect_limit: 3,
user_agent: "Discourse Forum Onebox",
}
end
end