Loading
Use Group#has_active_hooks? before building group webhook payloads
What does this MR do and why?
Group#has_active_hooks?` already exists in EE, but the member and subgroup webhook triggers still repeated the license and hook checks by hand. This MR makes them use the shared method, so a webhook payload is only built when a hook would actually receive it.
EE::Member#execute_hooks_fornow callssource.has_active_hooks?(:member_hooks). The old check matched any group hook, so payloads were built even when no hook hadmember_eventsenabled.EE::Group#execute_subgroup_hooksnow callsparent&.has_active_hooks?(:subgroup_hooks). The hooks fire from the parent, so the guard checks the parent instead of the subgroup's license.- Spec fix: clear the memoized
has_active_hooks?onparent_groupin the subgroup hooks spec, because the fixture createssubgroupbefore the hook exists.
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
bundle exec rspec ee/spec/models/ee/group_spec.rb -e "subgroup hooks" -e "#has_active_hooks?"
bundle exec rspec ee/spec/models/ee/member_spec.rb -e "post_create_hook" -e "post_update_hook"MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.