mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
d681decf01
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>
19 lines
463 B
Ruby
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
|