mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 23:33:57 +08:00
FIX: Support for cookies in onebox redirects
This commit is contained in:
parent
502bca2c0d
commit
075d0ecacc
2
Gemfile
2
Gemfile
|
@ -48,7 +48,7 @@ gem 'onebox'
|
||||||
gem 'http_accept_language', '~>2.0.5', require: false
|
gem 'http_accept_language', '~>2.0.5', require: false
|
||||||
|
|
||||||
gem 'ember-rails', '0.18.5'
|
gem 'ember-rails', '0.18.5'
|
||||||
gem 'ember-source', '2.10.0'
|
gem 'ember-source'
|
||||||
gem 'ember-handlebars-template', '0.7.5'
|
gem 'ember-handlebars-template', '0.7.5'
|
||||||
gem 'barber'
|
gem 'barber'
|
||||||
gem 'babel-transpiler'
|
gem 'babel-transpiler'
|
||||||
|
|
|
@ -214,7 +214,7 @@ GEM
|
||||||
omniauth-twitter (1.3.0)
|
omniauth-twitter (1.3.0)
|
||||||
omniauth-oauth (~> 1.1)
|
omniauth-oauth (~> 1.1)
|
||||||
rack
|
rack
|
||||||
onebox (1.8.8)
|
onebox (1.8.11)
|
||||||
fast_blank (>= 1.0.0)
|
fast_blank (>= 1.0.0)
|
||||||
htmlentities (~> 4.3)
|
htmlentities (~> 4.3)
|
||||||
moneta (~> 1.0)
|
moneta (~> 1.0)
|
||||||
|
@ -409,7 +409,7 @@ DEPENDENCIES
|
||||||
email_reply_trimmer (= 0.1.6)
|
email_reply_trimmer (= 0.1.6)
|
||||||
ember-handlebars-template (= 0.7.5)
|
ember-handlebars-template (= 0.7.5)
|
||||||
ember-rails (= 0.18.5)
|
ember-rails (= 0.18.5)
|
||||||
ember-source (= 2.10.0)
|
ember-source
|
||||||
excon
|
excon
|
||||||
execjs
|
execjs
|
||||||
fabrication (= 2.9.8)
|
fabrication (= 2.9.8)
|
||||||
|
|
|
@ -144,9 +144,17 @@ module Oneboxer
|
||||||
def self.onebox_raw(url)
|
def self.onebox_raw(url)
|
||||||
|
|
||||||
Rails.cache.fetch(onebox_cache_key(url), expires_in: 1.day) do
|
Rails.cache.fetch(onebox_cache_key(url), expires_in: 1.day) do
|
||||||
uri = FinalDestination.new(url).resolve
|
fd = FinalDestination.new(url)
|
||||||
|
uri = fd.resolve
|
||||||
return blank_onebox if uri.blank? || SiteSetting.onebox_domains_blacklist.include?(uri.hostname)
|
return blank_onebox if uri.blank? || SiteSetting.onebox_domains_blacklist.include?(uri.hostname)
|
||||||
options = { cache: {}, max_width: 695, sanitize_config: Sanitize::Config::DISCOURSE_ONEBOX }
|
options = {
|
||||||
|
cache: {},
|
||||||
|
max_width: 695,
|
||||||
|
sanitize_config: Sanitize::Config::DISCOURSE_ONEBOX
|
||||||
|
}
|
||||||
|
|
||||||
|
options[:cookie] = fd.cookie if fd.cookie
|
||||||
|
|
||||||
r = Onebox.preview(url, options)
|
r = Onebox.preview(url, options)
|
||||||
{ onebox: r.to_s, preview: r.try(:placeholder_html).to_s }
|
{ onebox: r.to_s, preview: r.try(:placeholder_html).to_s }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user