FIX: Award 'First Onebox' badge just for Oneboxed URLs. (#7974)

This commit is contained in:
Bianca Nenciu
2019-08-08 19:45:18 +03:00
committed by Régis Hanol
parent 922c40f87c
commit 7c83d2eeb2
2 changed files with 23 additions and 9 deletions

View File

@ -28,7 +28,7 @@ class CookedPostProcessor
@cooking_options = @cooking_options.symbolize_keys
@doc = Nokogiri::HTML::fragment(post.cook(post.raw, @cooking_options))
@has_oneboxes = post.post_analyzer.found_oneboxes?
@has_oneboxes = @doc.css("aside.onebox").count > 0
@size_cache = {}
@disable_loading_image = !!opts[:disable_loading_image]
@ -506,13 +506,14 @@ class CookedPostProcessor
map[url] = true
if is_onebox
@has_oneboxes = true
Oneboxer.onebox(url,
onebox = Oneboxer.onebox(url,
invalidate_oneboxes: !!@opts[:invalidate_oneboxes],
user_id: @post&.user_id,
category_id: @post&.topic&.category_id
)
@has_oneboxes = true if onebox.present?
onebox
else
process_inline_onebox(element)
false