diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-16 17:08:10 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-16 19:51:09 +0300 |
commit | 0f2776287a7d9b0fde9ff54ef8d9f74e2f844a09 (patch) | |
tree | b619ec2d6758f11fd3bb6ccc682688409e61d436 /lib/gitlab/chat_commands | |
parent | f9f1a508c6a4bdb2fcee98d18394e28e1cc663c3 (diff) |
Use Slack::Notifier::LinkFormatter to convert markdown links to slack compat
Diffstat (limited to 'lib/gitlab/chat_commands')
-rw-r--r-- | lib/gitlab/chat_commands/base_command.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/chat_commands/presenter.rb | 25 |
2 files changed, 4 insertions, 23 deletions
diff --git a/lib/gitlab/chat_commands/base_command.rb b/lib/gitlab/chat_commands/base_command.rb index 156bb826f86..4fe53ce93a9 100644 --- a/lib/gitlab/chat_commands/base_command.rb +++ b/lib/gitlab/chat_commands/base_command.rb @@ -44,7 +44,7 @@ module Gitlab end def presenter - Gitlab::ChatCommands::Presenter.new(params[:presenter_format]) + Gitlab::ChatCommands::Presenter.new end end end diff --git a/lib/gitlab/chat_commands/presenter.rb b/lib/gitlab/chat_commands/presenter.rb index 98356ebebb3..e94d0ce2470 100644 --- a/lib/gitlab/chat_commands/presenter.rb +++ b/lib/gitlab/chat_commands/presenter.rb @@ -3,15 +3,9 @@ module Gitlab class Presenter include Gitlab::Routing.url_helpers - attr_reader :format - - def initialize(format) - @format = format - end - def authorize_chat_name(url) message = if url - ":wave: Hi there! Before I do anything for you, please #{link(url, 'connect your GitLab account')}." + ":wave: Hi there! Before I do anything for you, please [connect your GitLab account](#{url})." else ":sweat_smile: Couldn't identify you, nor can I autorize you!" end @@ -49,7 +43,7 @@ module Gitlab end def access_denied - ephemeral_response("Whoops! That action is not allowed. This incident will be #{link('https://xkcd.com/838/', 'reported')}.") + ephemeral_response("Whoops! That action is not allowed. This incident will be [reported](https://xkcd.com/838/).") end private @@ -94,7 +88,7 @@ module Gitlab reference = resource.try(:to_reference) || resource.try(:id) title = resource.try(:title) || resource.try(:name) - link(url(resource), "#{reference} #{title}") + "[#{reference} #{title}](#{url(resource)})" end def header_with_list(header, items) @@ -132,19 +126,6 @@ module Gitlab status: 200 } end - - def link(url, title) - case format - when 'slack' - "<#{url}|#{title}>" - - when 'mattermost' - "[#{title}](#{url})" - - else - title - end - end end end end |