Notify chat integrations when a merge request review is requested
What does this MR do and why?
Chat notification integrations that build on the shared chat notification base, such as Discord, Slack, Microsoft Teams, and Pumble, stay silent when reviewers change on a merge request. Requesting a review, or having one requested of you, sends no message, even though the same integrations announce approvals, merges, and status changes.
The reason is that a reviewer change reaches the integration as a merge request webhook with the update action. The base class drops every update event to avoid duplicate messages after an open or close, so the reviewer change is dropped along with them. The webhook payload does carry the reviewer change under changes.reviewers, it just never gets used.
This builds a merge request chat message for an update event when the payload contains a reviewers change. It compares the previous and current reviewers to pick the wording and names the people involved: adding or requesting reviewers reads "requested a review from Jane Doe (jane) of", removing one while others remain reads "removed Jane Doe (jane) as reviewer from", and clearing them all reads "removed all reviewers from". Only the reviewers added or removed in the event are named. Every other update event, such as a title or description edit, is still skipped, so the duplicate messages the filter was added to prevent do not come back. The change sits in the shared base class and message builder, so all chat integrations get it, not only Discord.
A note on rollout
This adds a notification that users did not receive before, so it sits behind the chat_notify_reviewer_change feature flag (beta type, owned by group::project management) and is off by default. That keeps the rollout gradual and lets an instance turn the messages off if they turn out to be too noisy. rollout_issue_url is left blank for the rollout issue to be created from the Feature Flag Roll Out template.
References
Closes #517047
Screenshots or screen recordings
Text-only chat message change. Example message text:
Test User (test.user) requested a review from Marc Saleiko (msaleiko) of merge request !100 *Title* in project_name
How to set up and validate locally
- Enable the feature flag from the Rails console:
Feature.enable(:chat_notify_reviewer_change). - Configure a chat integration on a project, for example Discord notifications, with the merge request event enabled and a valid webhook URL.
- Open a merge request in that project.
- Add or request a reviewer, and confirm the channel receives a "requested a review from ..." message that names the reviewer.
- Remove one of several reviewers, and confirm a "removed ... as reviewer from" message that names the removed reviewer.
- Remove all reviewers, and confirm a "removed all reviewers from merge request" message.
- Edit the title or description, and confirm no message is sent for that update.
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.