mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:41:03 +08:00
FEATURE: New "First Onebox" badge
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user