2018-08-10 06:45:01 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-31 05:50:53 +00:00
|
|
|
class SlackSlashCommandsService < SlashCommandsService
|
2016-11-30 14:51:48 +00:00
|
|
|
include TriggersHelper
|
|
|
|
|
|
|
|
def title
|
2017-01-08 14:19:19 +00:00
|
|
|
'Slack slash commands'
|
2016-11-30 14:51:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
2017-01-08 14:19:19 +00:00
|
|
|
"Perform common operations in Slack"
|
2016-11-30 14:51:48 +00:00
|
|
|
end
|
|
|
|
|
2016-12-27 12:44:24 +00:00
|
|
|
def self.to_param
|
2016-11-30 14:51:48 +00:00
|
|
|
'slack_slash_commands'
|
|
|
|
end
|
2016-12-15 23:00:54 +00:00
|
|
|
|
2016-12-16 14:08:10 +00:00
|
|
|
def trigger(params)
|
|
|
|
# Format messages to be Slack-compatible
|
2016-12-19 12:32:37 +00:00
|
|
|
super.tap do |result|
|
2016-12-22 09:54:35 +00:00
|
|
|
result[:text] = format(result[:text]) if result.is_a?(Hash)
|
2016-12-16 14:08:10 +00:00
|
|
|
end
|
2016-12-19 12:32:37 +00:00
|
|
|
end
|
|
|
|
|
2019-02-20 21:29:48 +00:00
|
|
|
def chat_responder
|
|
|
|
::Gitlab::Chat::Responder::Slack
|
|
|
|
end
|
|
|
|
|
2016-12-19 12:32:37 +00:00
|
|
|
private
|
2016-12-16 14:08:10 +00:00
|
|
|
|
2016-12-19 12:32:37 +00:00
|
|
|
def format(text)
|
|
|
|
Slack::Notifier::LinkFormatter.format(text) if text
|
2016-12-15 23:00:54 +00:00
|
|
|
end
|
2016-11-30 14:51:48 +00:00
|
|
|
end
|