Class: Gitlab::SlashCommands::GlobalSlackHandler
- Inherits:
-
Object
- Object
- Gitlab::SlashCommands::GlobalSlackHandler
- Defined in:
- lib/gitlab/slash_commands/global_slack_handler.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#project_alias ⇒ Object
readonly
Returns the value of attribute project_alias.
Instance Method Summary collapse
-
#initialize(params) ⇒ GlobalSlackHandler
constructor
A new instance of GlobalSlackHandler.
- #trigger ⇒ Object
Constructor Details
#initialize(params) ⇒ GlobalSlackHandler
Returns a new instance of GlobalSlackHandler.
8 9 10 11 |
# File 'lib/gitlab/slash_commands/global_slack_handler.rb', line 8 def initialize(params) @project_alias, command = parse_command_text(params) @params = params.merge(text: command, original_command: params[:text]) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/gitlab/slash_commands/global_slack_handler.rb', line 6 def params @params end |
#project_alias ⇒ Object (readonly)
Returns the value of attribute project_alias.
6 7 8 |
# File 'lib/gitlab/slash_commands/global_slack_handler.rb', line 6 def project_alias @project_alias end |
Instance Method Details
#trigger ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab/slash_commands/global_slack_handler.rb', line 13 def trigger return false unless valid_token? return Gitlab::SlashCommands::ApplicationHelp.new(nil, params).execute if help_command? unless slack_integration = find_slack_integration = 'GitLab error: project or alias not found' return Gitlab::SlashCommands::Presenters::Error.new(). end chat_user = ChatNames::FindUserService.new(params[:team_id], params[:user_id]).execute integration = slack_integration.integration if chat_user&.user Gitlab::SlashCommands::Command.new(integration.project, chat_user, params).execute else url = ChatNames::AuthorizeUserService.new(params).execute Gitlab::SlashCommands::Presenters::Access.new(url). end end |