debian-mirror-gitlab/lib/gitlab/chat/responder.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
703 B
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
module Gitlab
module Chat
module Responder
# Returns an instance of the responder to use for generating chat
# responses.
#
# This method will return `nil` if no formatter is available for the given
# build.
#
# build - A `Ci::Build` that executed a chat command.
def self.responder_for(build)
2023-05-27 22:25:52 +05:30
response_url = build.pipeline.chat_data&.response_url
return unless response_url
2019-07-07 11:18:12 +05:30
2023-05-27 22:25:52 +05:30
if response_url.start_with?('https://hooks.slack.com/')
Gitlab::Chat::Responder::Slack.new(build)
2023-04-23 21:23:45 +05:30
else
2023-05-27 22:25:52 +05:30
Gitlab::Chat::Responder::Mattermost.new(build)
2019-07-07 11:18:12 +05:30
end
end
end
end
end