Class: Integrations::SlackSlashCommands

Inherits:
Integration show all
Includes:
Ci::TriggersHelper, Base::SlashCommands
Defined in:
app/models/integrations/slack_slash_commands.rb

Constant Summary collapse

SLACK_REDIRECT_URL =
'slack://channel?team=%{TEAM}&id=%{CHANNEL}'

Constants included from Base::SlashCommands

Base::SlashCommands::CACHE_EXPIRATION_TIME, Base::SlashCommands::CACHE_KEY

Constants included from Base::Integration

Base::Integration::BASE_ATTRIBUTES, Base::Integration::BASE_CLASSES, Base::Integration::DEV_INTEGRATION_NAMES, Base::Integration::INSTANCE_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::INTEGRATION_NAMES, Base::Integration::PROJECT_AND_GROUP_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::PROJECT_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::SECTION_TYPE_CONFIGURATION, Base::Integration::SECTION_TYPE_CONNECTION, Base::Integration::SECTION_TYPE_TRIGGER, Base::Integration::SNOWPLOW_EVENT_ACTION, Base::Integration::SNOWPLOW_EVENT_LABEL, Base::Integration::UnknownType

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ci::TriggersHelper

#builds_trigger_url, #integration_trigger_url

Methods included from Base::SlashCommands

#testable?, #valid_token?

Methods included from Base::Integration

#activate!, #activate_disabled_reason, #activated?, #api_field_names, #async_execute, #attributes, #attribution_notice, #category, #chat?, #ci?, #configurable_events, #deactivate!, #default_test_event, #description, #dup, #editable?, #event_channel_names, #event_names, #execute, #fields, #form_fields, #group_level?, #help, #inheritable?, #initialize_properties, #instance_level?, #json_fields, #manual_activation?, #operating?, #parent, #project_level?, #reencrypt_properties, #reset_updated_properties, #secret_fields, #sections, #supported_events, #supports_data_fields?, #test, #testable?, #title, #to_database_hash, #to_param, #toggle!, #updated_properties

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.descriptionObject



22
23
24
# File 'app/models/integrations/slack_slash_commands.rb', line 22

def self.description
  "Perform common operations in Slack."
end

.titleObject



18
19
20
# File 'app/models/integrations/slack_slash_commands.rb', line 18

def self.title
  'Slack slash commands'
end

.to_paramObject



26
27
28
# File 'app/models/integrations/slack_slash_commands.rb', line 26

def self.to_param
  'slack_slash_commands'
end

Instance Method Details

#confirmation_url(command_id, params) ⇒ Object



41
42
43
44
45
46
47
# File 'app/models/integrations/slack_slash_commands.rb', line 41

def confirmation_url(command_id, params)
  team, channel, response_url = params.values_at(:team_id, :channel_id, :response_url)

  Rails.application.routes.url_helpers.project_integrations_slash_commands_url(
    project, command_id: command_id, integration: to_param, team: team, channel: channel, response_url: response_url
  )
end

#redirect_url(team, channel, _url) ⇒ Object



37
38
39
# File 'app/models/integrations/slack_slash_commands.rb', line 37

def redirect_url(team, channel, _url)
  Kernel.format(SLACK_REDIRECT_URL, TEAM: team, CHANNEL: channel)
end

#trigger(params) ⇒ Object



30
31
32
33
34
35
# File 'app/models/integrations/slack_slash_commands.rb', line 30

def trigger(params)
  # Format messages to be Slack-compatible
  super.tap do |result|
    result[:text] = format(result[:text]) if result.is_a?(Hash)
  end
end