From 6a417c308f8abf30b0dec712426a009cabce859e Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Thu, 7 Nov 2019 15:42:11 +0530 Subject: [PATCH] FIX: include onebox default options in development environment --- config/initializers/100-onebox_options.rb | 19 ++++++++++++++----- lib/oneboxer.rb | 4 ---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/config/initializers/100-onebox_options.rb b/config/initializers/100-onebox_options.rb index e9d0f21c712..d98886e2ba3 100644 --- a/config/initializers/100-onebox_options.rb +++ b/config/initializers/100-onebox_options.rb @@ -1,7 +1,16 @@ # frozen_string_literal: true -Onebox.options = { - twitter_client: TwitterApi, - redirect_limit: 3, - user_agent: "Discourse Forum Onebox v#{Discourse::VERSION::STRING}" -} +if Rails.env.development? && SiteSetting.port.to_i > 0 + Onebox.options = { + twitter_client: TwitterApi, + redirect_limit: 3, + user_agent: "Discourse Forum Onebox v#{Discourse::VERSION::STRING}", + allowed_ports: [80, 443, SiteSetting.port.to_i] + } +else + Onebox.options = { + twitter_client: TwitterApi, + redirect_limit: 3, + user_agent: "Discourse Forum Onebox v#{Discourse::VERSION::STRING}" + } +end diff --git a/lib/oneboxer.rb b/lib/oneboxer.rb index 96245cf820a..fba6704045b 100644 --- a/lib/oneboxer.rb +++ b/lib/oneboxer.rb @@ -290,10 +290,6 @@ module Oneboxer options[:cookie] = fd.cookie if fd.cookie - if Rails.env.development? && SiteSetting.port.to_i > 0 - Onebox.options = { allowed_ports: [80, 443, SiteSetting.port.to_i] } - end - r = Onebox.preview(uri.to_s, options) { onebox: r.to_s, preview: r&.placeholder_html.to_s }