FEATURE: Webhooks and Event for user being granted a badge

Adding a webhook for badge revocation is left for future work as it's relatively rare.
This commit is contained in:
Kane York
2020-04-08 11:34:35 -07:00
committed by Kane York
parent 14467757df
commit 138d4aebde
7 changed files with 57 additions and 1 deletions

View File

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