Class: Integrations::Irker

Inherits:
Integration show all
Defined in:
app/models/integrations/irker.rb

Constant Summary

Constants inherited from Integration

Integration::BASE_CLASSES, Integration::DEV_INTEGRATION_NAMES, Integration::INTEGRATION_NAMES, Integration::PROJECT_SPECIFIC_INTEGRATION_NAMES, Integration::SECTION_TYPE_CONNECTION, Integration::UnknownType

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Instance Attribute Summary

Attributes included from Importable

#imported, #importing

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Integration

#activate_disabled_reason, #activated?, #api_field_names, #async_execute, #attributes, available_integration_names, available_integration_types, boolean_accessor, build_from_integration, #category, #configurable_events, create_from_active_default_integrations, default_integration, #default_test_event, default_test_event, dev_integration_names, #dup, #editable?, #event_channel_names, event_description, #event_field, event_names, #event_names, field, fields, find_or_initialize_all_non_project_specific, find_or_initialize_non_project_specific_integration, #global_fields, #group_level?, #inheritable?, inherited_descendants_from_self_or_ancestors_from, #initialize_properties, instance_exists_for?, #instance_level?, integration_name_to_model, integration_name_to_type, integration_names, #json_fields, #operating?, #parent, #project_level?, project_specific_integration_names, prop_accessor, #properties=, #reencrypt_properties, #reset_updated_properties, #secret_fields, #sections, #show_active_box?, #supported_events, #supports_data_fields?, #test, #testable?, #to_data_fields_hash, #to_integration_hash, #to_param, #updated_properties

Methods included from Gitlab::Utils::Override

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

Methods included from ResetSecretFields

#exposing_secrets_fields

Methods included from Loggable

#build_message, #log_error, #log_exception, #log_info, #logger

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, 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 SensitiveSerializableHash

#serializable_hash

Class Method Details

.supported_eventsObject


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

def self.supported_events
  %w(push)
end

.to_paramObject


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

def self.to_param
  'irker'
end

Instance Method Details

#descriptionObject


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

def description
  s_('IrkerService|Send update messages to an irker server.')
end

#execute(data) ⇒ Object


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

def execute(data)
  return unless supported_events.include?(data[:object_kind])

  IrkerWorker.perform_async(project_id, channels,
                            colorize_messages, data, settings)
end

#fieldsObject


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/models/integrations/irker.rb', line 44

def fields
  recipients_docs_link = ActionController::Base.helpers.link_to s_('IrkerService|How to enter channels or users?'), Rails.application.routes.url_helpers.help_page_url('user/project/integrations/irker', anchor: 'enter-irker-recipients'), target: '_blank', rel: 'noopener noreferrer'
  [
    { type: 'text', name: 'server_host', placeholder: 'localhost', title: s_('IrkerService|Server host (optional)'),
      help: s_('IrkerService|irker daemon hostname (defaults to localhost).') },
    { type: 'text', name: 'server_port', placeholder: 6659, title: s_('IrkerService|Server port (optional)'),
      help: s_('IrkerService|irker daemon port (defaults to 6659).') },
    { type: 'text', name: 'default_irc_uri', title: s_('IrkerService|Default IRC URI (optional)'),
      help: s_('IrkerService|URI to add before each recipient.'),
      placeholder: 'irc://irc.network.net:6697/' },
    { type: 'textarea', name: 'recipients', title: s_('IrkerService|Recipients'),
      placeholder: 'irc[s]://irc.network.net[:port]/#channel', required: true,
      help: s_('IrkerService|Channels and users separated by whitespaces. %{recipients_docs_link}').html_safe % { recipients_docs_link: recipients_docs_link.html_safe } },
    { type: 'checkbox', name: 'colorize_messages', title: _('Colorize messages') }
  ]
end

#helpObject


61
62
63
64
# File 'app/models/integrations/irker.rb', line 61

def help
  docs_link = ActionController::Base.helpers.link_to _('Learn more.'), Rails.application.routes.url_helpers.help_page_url('user/project/integrations/irker', anchor: 'set-up-an-irker-daemon'), target: '_blank', rel: 'noopener noreferrer'
  s_('IrkerService|Send update messages to an irker server. Before you can use this, you need to set up the irker daemon. %{docs_link}').html_safe % { docs_link: docs_link.html_safe }
end

#settingsObject


37
38
39
40
41
42
# File 'app/models/integrations/irker.rb', line 37

def settings
  {
    server_host: server_host.presence || 'localhost',
    server_port: server_port.presence || 6659
  }
end

#titleObject


14
15
16
# File 'app/models/integrations/irker.rb', line 14

def title
  s_('IrkerService|irker (IRC gateway)')
end