From e6a6c8db07a8da0a1215456f1d60caaf43560915 Mon Sep 17 00:00:00 2001 From: Amanda Alves Branquinho Date: Wed, 30 Oct 2024 18:03:20 -0300 Subject: [PATCH] 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 --- app/controllers/user_badges_controller.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/user_badges_controller.rb b/app/controllers/user_badges_controller.rb index e06701e6ee7..c701fde9b73 100644 --- a/app/controllers/user_badges_controller.rb +++ b/app/controllers/user_badges_controller.rb @@ -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