Support for events in the Slack integration
Problem
A ton of events aren't set to Slack via the project integration. The only events are Open, Close, and Comment.
This is due to the code we have in https://gitlab.com/gitlab-org/gitlab/-/blob/26262d66a961ba06906648027c27b58067af19c6/app/models/project_services/chat_notification_service.rb#L130-133:
when "issue"
ChatMessage::IssueMessage.new(data) unless update?(data)
when "merge_request"
ChatMessage::MergeMessage.new(data) unless update?(data)
This explicitly skips update events for issues and MRs. Comment in the file says:
# WebHook events often have an 'update' event that follows a 'open' or
# 'close' action. Ignore update events for now to prevent duplicate
# messages from arriving.
Looks like it has been this way since the Slack integration was first introduced in gitlab-foss@afe5d7d2. It's a community contribution from @stanhu almost 6 years ago
I think this was done because in ChatMessage::IssueMessage, we can see that we only send messages in the format: Issue #{issue_link} #{state} by #{user_combined_name}. state here is the current issue state. So it would be odd to keep on receiving Issue opened by ... when it was actually because of updates to the issue.
Proposal
So to fix this we'd have to support a different message for these updates so that it isn't confusing to users. Even just a simple Issue xxx updated by .. would probably be fine as a first iteration. Though I see that the payload has a changes attribute which we could probably use to further customize the message depending on the update that was done.