mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: multiple grant not working correctly
This commit is contained in:
parent
c2fa382471
commit
650e9348f3
2 changed files with 8 additions and 2 deletions
|
@ -26,7 +26,7 @@ module Jobs
|
|||
user = post.user
|
||||
|
||||
# Grant "Welcome" badge to the user if they do not already have it.
|
||||
BadgeGranter.grant(Badge.find(5), user)
|
||||
BadgeGranter.grant(Badge.find(Badge::Welcome), user)
|
||||
|
||||
Badge.like_badge_counts.each do |badge_id, count|
|
||||
if post.like_count >= count
|
||||
|
|
|
@ -13,7 +13,13 @@ class BadgeGranter
|
|||
def grant
|
||||
return if @granted_by and !Guardian.new(@granted_by).can_grant_badges?(@user)
|
||||
|
||||
user_badge = UserBadge.find_by(badge_id: @badge.id, user_id: @user.id, post_id: @post_id)
|
||||
find_by = { badge_id: @badge.id, user_id: @user.id }
|
||||
|
||||
if @badge.multiple_grant?
|
||||
find_by[:post_id] = @post_id
|
||||
end
|
||||
|
||||
user_badge = UserBadge.find_by(find_by)
|
||||
|
||||
if user_badge.nil? || (@badge.multiple_grant? && @post_id.nil?)
|
||||
UserBadge.transaction do
|
||||
|
|
Loading…
Reference in a new issue