diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-19 06:12:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-19 06:12:19 +0300 |
commit | b0c61201a70f1980dc5a2454d979b95415455d14 (patch) | |
tree | f2feba66723dd0041676ad0c2ffb61e45eaf545d /app/models | |
parent | 65530963a354e3e74971b775c16066bd9d76c63c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/integrations/hangouts_chat.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/app/models/integrations/hangouts_chat.rb b/app/models/integrations/hangouts_chat.rb index df112ad6ca8..6e7f31aa030 100644 --- a/app/models/integrations/hangouts_chat.rb +++ b/app/models/integrations/hangouts_chat.rb @@ -47,8 +47,31 @@ module Integrations private def notify(message, opts) + url = webhook.dup + + key = parse_thread_key(message) + url = Gitlab::Utils.add_url_parameters(url, { threadKey: key }) if key + simple_text = parse_simple_text_message(message) - ::HangoutsChat::Sender.new(webhook).simple(simple_text) + ::HangoutsChat::Sender.new(url).simple(simple_text) + end + + # Returns an appropriate key for threading messages in google chat + def parse_thread_key(message) + case message + when Integrations::ChatMessage::NoteMessage + message.target + when Integrations::ChatMessage::IssueMessage + "issue #{Issue.reference_prefix}#{message.issue_iid}" + when Integrations::ChatMessage::MergeMessage + "merge request #{MergeRequest.reference_prefix}#{message.merge_request_iid}" + when Integrations::ChatMessage::PushMessage + "push #{message.project_name}_#{message.ref}" + when Integrations::ChatMessage::PipelineMessage + "pipeline #{message.pipeline_id}" + when Integrations::ChatMessage::WikiPageMessage + "wiki_page #{message.wiki_page_url}" + end end def parse_simple_text_message(message) |