BigW Consortium Gitlab

slack_slash_commands_service.rb 517 Bytes
Newer Older
1
class SlackSlashCommandsService < SlashCommandsService
2 3 4
  include TriggersHelper

  def title
5
    'Slack slash commands'
6 7 8
  end

  def description
9
    "Perform common operations in Slack"
10 11
  end

12
  def self.to_param
13 14
    'slack_slash_commands'
  end
15

16 17
  def trigger(params)
    # Format messages to be Slack-compatible
Kamil Trzcinski committed
18
    super.tap do |result|
19
      result[:text] = format(result[:text]) if result.is_a?(Hash)
20
    end
Kamil Trzcinski committed
21 22 23
  end

  private
24

Kamil Trzcinski committed
25 26
  def format(text)
    Slack::Notifier::LinkFormatter.format(text) if text
27
  end
28
end