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_for now calls source.has_active_hooks?(:member_hooks). The old check matched any group hook, so payloads were built even when no hook had member_events enabled.
  • EE::Group#execute_subgroup_hooks now calls parent&.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? on parent_group in the subgroup hooks spec, because the fixture creates subgroup before the hook exists.

References

#517890

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.

Merge request reports

Loading
Loading