diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-02-22 18:34:04 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-02-23 14:37:53 +0100 |
commit | 57719d34d3fcc15f39354b0e9dc1da41bbe5d1a8 (patch) | |
tree | 255d9a3df371793748c64792a715102dca98512c /lib | |
parent | c679fa163148601e77803f45cf5dea8e1b3feb0a (diff) | |
download | gitlab-ce-57719d34d3fcc15f39354b0e9dc1da41bbe5d1a8.tar.gz |
Expose ChatName objects to slash commandsslash-commands-changes-for-chatops
Instead of only exposing a User to slash commands we now also expose the
ChatName object that the User object is retrieved from. This is
necessary for GitLab Chatops as we need for example the user ID of the
chat user.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/slash_commands/base_command.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/slash_commands/command.rb | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/gitlab/slash_commands/base_command.rb b/lib/gitlab/slash_commands/base_command.rb index cc3c9a50555..466554e398c 100644 --- a/lib/gitlab/slash_commands/base_command.rb +++ b/lib/gitlab/slash_commands/base_command.rb @@ -31,10 +31,11 @@ module Gitlab raise NotImplementedError end - attr_accessor :project, :current_user, :params + attr_accessor :project, :current_user, :params, :chat_name - def initialize(project, user, params = {}) - @project, @current_user, @params = project, user, params.dup + def initialize(project, chat_name, params = {}) + @project, @current_user, @params = project, chat_name.user, params.dup + @chat_name = chat_name end private diff --git a/lib/gitlab/slash_commands/command.rb b/lib/gitlab/slash_commands/command.rb index a78408b0519..85aaa6b0eba 100644 --- a/lib/gitlab/slash_commands/command.rb +++ b/lib/gitlab/slash_commands/command.rb @@ -13,12 +13,13 @@ module Gitlab if command if command.allowed?(project, current_user) - command.new(project, current_user, params).execute(match) + command.new(project, chat_name, params).execute(match) else Gitlab::SlashCommands::Presenters::Access.new.access_denied end else - Gitlab::SlashCommands::Help.new(project, current_user, params).execute(available_commands, params[:text]) + Gitlab::SlashCommands::Help.new(project, chat_name, params) + .execute(available_commands, params[:text]) end end |