Class: MattermostSlashCommandsService

Inherits:
SlashCommandsService show all
Includes:
TriggersHelper
Defined in:
app/models/project_services/mattermost_slash_commands_service.rb

Constant Summary

Constants inherited from Service

Service::DEV_SERVICE_NAMES, Service::SERVICE_NAMES

Instance Attribute Summary

Attributes included from Importable

#imported, #importing

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TriggersHelper

#builds_trigger_url, #service_trigger_url

Methods inherited from SlashCommandsService

#fields, supported_events, #trigger, #valid_token?

Methods inherited from Service

#activated?, #api_field_names, #async_execute, available_services_names, available_services_types, boolean_accessor, build_from_integration, #category, #configurable_event_actions, #configurable_events, default_integration, dev_services_names, #editable?, #event_channel_names, event_description, #event_field, #event_names, event_names, #execute, #fields, find_or_create_templates, find_or_initialize_all, find_or_initialize_integration, #global_fields, #help, #initialize_properties, instance_exists_for?, #issue_tracker?, #json_fields, #operating?, prop_accessor, #reset_updated_properties, services_names, services_types, #show_active_box?, supported_event_actions, #supported_events, supported_events, #supports_data_fields?, #test, #to_data_fields_hash, #to_param, #to_service_hash, #updated_properties

Methods included from ProjectServicesLoggable

#build_message, #log_error, #log_info, #logger

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.to_paramObject


20
21
22
# File 'app/models/project_services/mattermost_slash_commands_service.rb', line 20

def self.to_param
  'mattermost_slash_commands'
end

Instance Method Details

#can_test?Boolean

Returns:

  • (Boolean)

8
9
10
# File 'app/models/project_services/mattermost_slash_commands_service.rb', line 8

def can_test?
  false
end

#chat_responderObject


39
40
41
# File 'app/models/project_services/mattermost_slash_commands_service.rb', line 39

def chat_responder
  ::Gitlab::Chat::Responder::Mattermost
end

#configure(user, params) ⇒ Object


24
25
26
27
28
29
30
31
# File 'app/models/project_services/mattermost_slash_commands_service.rb', line 24

def configure(user, params)
  token = Mattermost::Command.new(user)
    .create(command(params))

  update(active: true, token: token) if token
rescue Mattermost::Error => e
  [false, e.message]
end

#descriptionObject


16
17
18
# File 'app/models/project_services/mattermost_slash_commands_service.rb', line 16

def description
  "Perform common operations in Mattermost"
end

#list_teams(current_user) ⇒ Object


33
34
35
36
37
# File 'app/models/project_services/mattermost_slash_commands_service.rb', line 33

def list_teams(current_user)
  [Mattermost::Team.new(current_user).all, nil]
rescue Mattermost::Error => e
  [[], e.message]
end

#titleObject


12
13
14
# File 'app/models/project_services/mattermost_slash_commands_service.rb', line 12

def title
  'Mattermost slash commands'
end