2016-12-15 17:45:10 -05:00
|
|
|
class SlackSlashCommandsService < ChatSlashCommandsService
|
2016-11-30 09:51:48 -05:00
|
|
|
include TriggersHelper
|
|
|
|
|
|
|
|
def title
|
2016-12-18 17:32:53 -05:00
|
|
|
'Slack Command'
|
2016-11-30 09:51:48 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
"Perform common operations on GitLab in Slack"
|
|
|
|
end
|
|
|
|
|
2016-12-27 07:44:24 -05:00
|
|
|
def self.to_param
|
2016-11-30 09:51:48 -05:00
|
|
|
'slack_slash_commands'
|
|
|
|
end
|
2016-12-15 18:00:54 -05:00
|
|
|
|
2016-12-16 09:08:10 -05:00
|
|
|
def trigger(params)
|
|
|
|
# Format messages to be Slack-compatible
|
2016-12-19 07:32:37 -05:00
|
|
|
super.tap do |result|
|
2016-12-22 04:54:35 -05:00
|
|
|
result[:text] = format(result[:text]) if result.is_a?(Hash)
|
2016-12-16 09:08:10 -05:00
|
|
|
end
|
2016-12-19 07:32:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2016-12-16 09:08:10 -05:00
|
|
|
|
2016-12-19 07:32:37 -05:00
|
|
|
def format(text)
|
|
|
|
Slack::Notifier::LinkFormatter.format(text) if text
|
2016-12-15 18:00:54 -05:00
|
|
|
end
|
2016-11-30 09:51:48 -05:00
|
|
|
end
|