mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 13:52:50 +08:00
Tweak badge granter not to try to double grant
This commit is contained in:
parent
cfccf8b4ed
commit
0d114d7b17
|
@ -12,8 +12,9 @@ class BadgeGranter
|
|||
def grant
|
||||
return if @granted_by and !Guardian.new(@granted_by).can_grant_badges?(@user)
|
||||
|
||||
user_badge = nil
|
||||
user_badge = UserBadge.find_by(badge_id: @badge.id, user_id: @user.id)
|
||||
|
||||
unless user_badge
|
||||
UserBadge.transaction do
|
||||
user_badge = UserBadge.create!(badge: @badge, user: @user,
|
||||
granted_by: @granted_by, granted_at: Time.now)
|
||||
|
@ -23,6 +24,7 @@ class BadgeGranter
|
|||
StaffActionLogger.new(@granted_by).log_badge_grant(user_badge)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
user_badge
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user