Class: SlashCommandsService
- Inherits:
-
Service
- Object
- ActiveRecord::Base
- ApplicationRecord
- Service
- SlashCommandsService
- Defined in:
- app/models/project_services/slash_commands_service.rb
Overview
Base class for Chat services This class is not meant to be used directly, but only to inherrit from.
Direct Known Subclasses
Constant Summary
Constants inherited from Service
Service::DEV_SERVICE_NAMES, Service::PROJECT_SPECIFIC_SERVICE_NAMES, Service::SERVICE_NAMES
Instance Attribute Summary
Attributes included from Importable
Class Method Summary collapse
Instance Method Summary collapse
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, create_from_active_default_integrations, default_integration, #default_test_event, default_test_event, #description, dev_services_names, #editable?, #event_channel_names, event_description, #event_field, event_names, #event_names, #execute, #external_issue_tracker?, #external_wiki?, find_or_create_templates, find_or_initialize_all_non_project_specific, find_or_initialize_non_project_specific_integration, #global_fields, #help, inherited_descendants_from_self_or_ancestors_from, #initialize_properties, instance_exists_for?, #json_fields, #operating?, project_specific_services_names, prop_accessor, #reset_updated_properties, services_names, #show_active_box?, supported_event_actions, #supported_events, #supports_data_fields?, #test, #title, #to_data_fields_hash, #to_param, 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, where_exists, with_fast_statement_timeout, without_order
Class Method Details
.supported_events ⇒ Object
18 19 20 |
# File 'app/models/project_services/slash_commands_service.rb', line 18 def self.supported_events %w() end |
Instance Method Details
#can_test? ⇒ Boolean
22 23 24 |
# File 'app/models/project_services/slash_commands_service.rb', line 22 def can_test? false end |
#fields ⇒ Object
26 27 28 29 30 |
# File 'app/models/project_services/slash_commands_service.rb', line 26 def fields [ { type: 'text', name: 'token', placeholder: 'XXxxXXxxXXxxXXxxXXxxXXxx' } ] end |
#trigger(params) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/project_services/slash_commands_service.rb', line 32 def trigger(params) return unless valid_token?(params[:token]) chat_user = find_chat_user(params) user = chat_user&.user if 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 Gitlab::SlashCommands::Command.new(project, chat_user, params).execute else url = (params) Gitlab::SlashCommands::Presenters::Access.new(url). end end |
#valid_token?(token) ⇒ Boolean
12 13 14 15 16 |
# File 'app/models/project_services/slash_commands_service.rb', line 12 def valid_token?(token) self.respond_to?(:token) && self.token.present? && ActiveSupport::SecurityUtils.secure_compare(token, self.token) end |