summaryrefslogtreecommitdiff
path: root/lib/gitlab/chat_commands/command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/chat_commands/command.rb')
-rw-r--r--lib/gitlab/chat_commands/command.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/gitlab/chat_commands/command.rb b/lib/gitlab/chat_commands/command.rb
index 0ed51d9b8fc..43144975901 100644
--- a/lib/gitlab/chat_commands/command.rb
+++ b/lib/gitlab/chat_commands/command.rb
@@ -9,9 +9,11 @@ module Gitlab
def execute
klass, match = fetch_klass
- return help(help_messages, params[:command]) unless klass.try(:available?, project)
-
- klass.new(project, current_user, params).execute(match)
+ if klass
+ present klass.new(project, current_user, params).execute(match)
+ else
+ help(help_messages)
+ end
end
private
@@ -40,6 +42,14 @@ module Gitlab
def command
params[:text]
end
+
+ def present(resource)
+ Mattermost::Presenter.present(resource)
+ end
+
+ def help(messages)
+ Mattermost::Presenter.help(messages, params[:command])
+ end
end
end
end