FIX: prevents double user_badge_granted event (#16654)

This bug was causing double events to be fired as :user_badge_granted is already called when a `user_badge` is created. More over the signature of the block in the UserBadge code is `badge_id, user_id` not `badge, user_id`.
This commit is contained in:
Joffrey JAFFEUX 2022-05-05 15:09:41 +02:00 committed by GitHub
parent 8c8b646a59
commit 81580e559c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 5 deletions

View File

@ -495,7 +495,7 @@ class BadgeGranter
end
def self.send_notification(user_id, username, locale, badge)
notification = I18n.with_locale(notification_locale(locale)) do
I18n.with_locale(notification_locale(locale)) do
Notification.create!(
user_id: user_id,
notification_type: Notification.types[:granted_badge],
@ -508,10 +508,6 @@ class BadgeGranter
}.to_json
)
end
DiscourseEvent.trigger(:user_badge_granted, badge, user_id)
notification
end
def self.suppress_notification?(badge, granted_at, skip_new_user_tips)