Fix webhook event logic in RemoveApprovalService

What does this MR do and why?

Fix webhook event logic in RemoveApprovalService

The previous logic incorrectly sent 'unapproved' webhook events whenever an approval was removed from a merge request that was previously approved, regardless of whether the merge request remained approved after the removal.

This change improves the logic by:

  • Checking approval state before AND after the removal
  • Only sending 'unapproved' when MR transitions from approved to not approved
  • Sending 'unapproval' for individual approval removals that don't change overall state

Before:

  • MR with 3 approvals (2 required) → remove 1 approval → sends 'unapproved'
  • This was incorrect since MR is still approved with 2/2 approvals

After:

  • MR with 3 approvals (2 required) → remove 1 approval → sends 'unapproval'
  • MR with 2 approvals (2 required) → remove 1 approval → sends 'unapproved'

The 'unapproved' event now correctly represents a state transition (approved → not approved) while 'unapproval' represents an individual action (approval removed).

Changelog: fixed EE: true

References

Resolves #558252 (closed)

Screenshots or screen recordings

Before After

How to set up and validate locally

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