DEV:refactor user badges create to get grant opts from method (#29372)

* DEV:refactor user badges create to get grant opts from method

* Replace method overwrite with plugin modifier

* Add aditional params

* change modifier name
This commit is contained in:
Amanda Alves Branquinho 2024-10-30 18:03:20 -03:00 committed by GitHub
parent 81396467d0
commit e6a6c8db07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -103,7 +103,14 @@ class UserBadgesController < ApplicationController
end
end
user_badge = BadgeGranter.grant(badge, user, granted_by: current_user, post_id: post_id)
grant_opts_from_params =
DiscoursePluginRegistry.apply_modifier(
:user_badges_badge_grant_opts,
{ granted_by: current_user, post_id: post_id },
{ param: params },
)
user_badge = BadgeGranter.grant(badge, user, grant_opts_from_params)
render_serialized(user_badge, DetailedUserBadgeSerializer, root: "user_badge")
end