FEATURE: New "First Onebox" badge

This commit is contained in:
Robin Ward
2016-04-12 14:09:59 -04:00
parent 04c1d37e63
commit 0396b14b70
9 changed files with 55 additions and 7 deletions

View File

@ -17,7 +17,10 @@ class CookedPostProcessor
@cooking_options = post.cooking_options || opts[:cooking_options] || {}
@cooking_options[:topic_id] = post.topic_id
@cooking_options = @cooking_options.symbolize_keys
@doc = Nokogiri::HTML::fragment(post.cook(post.raw, @cooking_options))
analyzer = post.post_analyzer
@doc = Nokogiri::HTML::fragment(analyzer.cook(post.raw, @cooking_options))
@has_oneboxes = analyzer.found_oneboxes?
@size_cache = {}
end
@ -46,9 +49,8 @@ class CookedPostProcessor
def grant_badges
return unless Guardian.new.can_see?(@post)
if has_emoji?
BadgeGranter.grant(Badge.find(Badge::FirstEmoji), @post.user)
end
BadgeGranter.grant(Badge.find(Badge::FirstEmoji), @post.user) if has_emoji?
BadgeGranter.grant(Badge.find(Badge::FirstOnebox), @post.user) if @has_oneboxes
end
def keep_reverse_index_up_to_date
@ -286,6 +288,7 @@ class CookedPostProcessor
# apply oneboxes
Oneboxer.apply(@doc, topic_id: @post.topic_id) { |url|
@has_oneboxes = true
Oneboxer.onebox(url, args)
}