mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
BUGFIX: Don't resolve oneboxes when cooking
Defer to post save job
This commit is contained in:
@@ -22,13 +22,24 @@ module Oneboxer
|
||||
def self.preview(url, options=nil)
|
||||
options ||= {}
|
||||
Oneboxer.invalidate(url) if options[:invalidate_oneboxes]
|
||||
Onebox.preview(url, cache: Rails.cache).placeholder_html
|
||||
onebox_raw(url).placeholder_html
|
||||
end
|
||||
|
||||
def self.onebox(url, options=nil)
|
||||
options ||= {}
|
||||
Oneboxer.invalidate(url) if options[:invalidate_oneboxes]
|
||||
Onebox.preview(url, cache: Rails.cache).to_s
|
||||
onebox_raw(url).to_s
|
||||
end
|
||||
|
||||
def self.cached_onebox(url)
|
||||
Rails.cache.read(onebox_cache_key(url))
|
||||
.to_s
|
||||
end
|
||||
|
||||
def self.cached_preview(url)
|
||||
Rails.cache.read(onebox_cache_key(url))
|
||||
.try(:placeholder_html)
|
||||
.to_s
|
||||
end
|
||||
|
||||
def self.oneboxer_exists_for_url?(url)
|
||||
@@ -36,7 +47,7 @@ module Oneboxer
|
||||
end
|
||||
|
||||
def self.invalidate(url)
|
||||
Rails.cache.delete(url)
|
||||
Rails.cache.delete(onebox_cache_key(url))
|
||||
end
|
||||
|
||||
# Parse URLs out of HTML, returning the document when finished.
|
||||
@@ -82,5 +93,16 @@ module Oneboxer
|
||||
Result.new(doc, changed)
|
||||
end
|
||||
|
||||
private
|
||||
def self.onebox_cache_key(url)
|
||||
"onebox_#{url}"
|
||||
end
|
||||
|
||||
def self.onebox_raw(url)
|
||||
Rails.cache.fetch(onebox_cache_key(url)){
|
||||
Onebox.preview(url, cache: {})
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user