Module: Integrations::Base::SlashCommands
- Extended by:
- ActiveSupport::Concern
- Included in:
- SlackSlashCommands
- Defined in:
- app/models/concerns/integrations/base/slash_commands.rb
Constant Summary collapse
- CACHE_KEY =
"slash-command-requests:%{secret}"
- CACHE_EXPIRATION_TIME =
3.minutes
Instance Method Summary collapse
Instance Method Details
#testable? ⇒ Boolean
50 51 52 |
# File 'app/models/concerns/integrations/base/slash_commands.rb', line 50 def testable? false end |
#trigger(params) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/concerns/integrations/base/slash_commands.rb', line 22 def trigger(params) return unless valid_token?(params[:token]) chat_user = find_chat_user(params) user = chat_user&.user return (params) unless user unless user.can?(:use_slash_commands) return Gitlab::SlashCommands::Presenters::Access.new.deactivated if user.deactivated? return Gitlab::SlashCommands::Presenters::Access.new.access_denied(project) end if Gitlab::SlashCommands::VerifyRequest.new(self, chat_user).valid? Gitlab::SlashCommands::Command.new(project, chat_user, params).execute else command_id = cache_slash_commands_request!(params) Gitlab::SlashCommands::Presenters::Access.new.confirm(confirmation_url(command_id, params)) end end |
#valid_token?(token) ⇒ Boolean
44 45 46 47 48 |
# File 'app/models/concerns/integrations/base/slash_commands.rb', line 44 def valid_token?(token) respond_to?(:token) && self.token.present? && ActiveSupport::SecurityUtils.secure_compare(token, self.token) end |