Add filter to webhooks

What does this MR do and why?

Webhooks currently fire in many situations where we then have to ignore when we receive them based on filter criteria.

We introduced filter evaluator in !223472 (merged) to allow us to configure/evaluate dynamic filters.

This MR goes the next step and introduces the database column to store the filter and the business logic to evaluate. There is currently no API/UI, that will be handled in a follow-up.

Similarly, we will address group and system hooks later 👍

References

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Setup a project webhook (for emoji events- just use https://example.com/test or something)
  2. Add an emoji to an issue in the project
  3. Edit the webhook and ensure you see the recent event
  4. Add a filter to the hook using the rails console:
    h = WebHook.last
    h.filter = {"emoji_hooks"=>{"rules"=>[{"field"=>"work_item.state", "operator"=>"ne", "value"=>"opened"}]}}
    h.save
  5. Add another emoji
  6. Edit the webhook and ensure you do not see any new events
  7. Close the issue
  8. Add another emoji
  9. Edit the webhook and ensure you see the recent event

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.

Edited by Lee Tickett

Merge request reports

Loading