DEV: Add deprecation warning for user_badge_removed event (#21255)

`user_badge_removed` event has been replaced with `user_badge_revoked`
This commit is contained in:
Selase Krakani 2023-04-27 13:07:02 +00:00 committed by GitHub
parent e49d338c21
commit 552697e194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -49,7 +49,6 @@ class UserBadge < ActiveRecord::Base
UserStat.update_distinct_badge_count self.user_id
UserBadge.update_featured_ranks! self.user_id
# TODO: Follow up with a deprecation notice for `user_badge_removed`
DiscourseEvent.trigger(:user_badge_removed, self.badge_id, self.user_id)
DiscourseEvent.trigger(:user_badge_revoked, user_badge: self)
end

View File

@ -21,6 +21,16 @@ class DiscourseEvent
raise_error: true,
)
end
if event_name == :user_badge_removed
Discourse.deprecate(
"The :user_badge_removed event is deprecated. Please use :user_badge_revoked instead",
since: "3.1.0.beta5",
drop_from: "3.2.0.beta1",
output_in_test: true,
)
end
events[event_name] << block
end