Skip to content

Implement #has_active_hooks? for Group (to mirror Project) to check before building webhook payloads

This issue was created from this discussion.

About

Project#has_active_hooks? is a small optimization that lets us check if a project (or any of its ancestor groups, or system hooks) is configured with the given webhook - before we build a webhook payload (which can involve fetching extra records). This means we will avoid creating the payload unless we know we will be triggering at least one webhook.

The Group model does not have a similar optimisation. However we have some custom code doing essentially this in Member.

Proposal

We should add a Group#has_active_hooks? method. The code would be in EE (as Group hooks is an EE-only feature)

This method can likely follow similar Project#has_active_hooks? method.

We would update any areas of the codebase that call group webhooks to check this method before building the payload - for example:

  • Member we would refactor these lines to use the method instead.
  • Group we would refactor this line to use the method instead.

And there may be more areas.

Edited by Luke Duncalfe