Class: IrkerService

Inherits:
Service
  • Object
show all
Defined in:
app/models/project_services/irker_service.rb

Instance Method Summary collapse

Methods inherited from Service

#activated?, #async_execute, available_services_names, boolean_accessor, #can_test?, #category, create_from_template, #initialize_properties, #issue_tracker?, prop_accessor, #reset_updated_properties, #template?, #test, #updated_properties

Instance Method Details

#descriptionObject


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

def description
  'Send IRC messages, on update, to a list of recipients through an Irker '\
  'gateway.'
end

#execute(data) ⇒ Object


51
52
53
54
55
56
# File 'app/models/project_services/irker_service.rb', line 51

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

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

#fieldsObject


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'app/models/project_services/irker_service.rb', line 64

def fields
  [
    { type: 'text', name: 'server_host', placeholder: 'localhost',
      help: 'Irker daemon hostname (defaults to localhost)' },
    { type: 'text', name: 'server_port', placeholder: 6659,
      help: 'Irker daemon port (defaults to 6659)' },
    { type: 'text', name: 'default_irc_uri', title: 'Default IRC URI',
      help: 'A default IRC URI to prepend before each recipient (optional)',
      placeholder: 'irc://irc.network.net:6697/' },
    { type: 'textarea', name: 'recipients',
      placeholder: 'Recipients/channels separated by whitespaces',
      help: 'Recipients have to be specified with a full URI: '\
      'irc[s]://irc.network.net[:port]/#channel. Special cases: if '\
      'you want the channel to be a nickname instead, append ",isnick" to ' \
      'the channel name; if the channel is protected by a secret password, ' \
      ' append "?key=secretpassword" to the URI (Note that due to a bug, if you ' \
      ' want to use a password, you have to omit the "#" on the channel). If you ' \
      ' specify a default IRC URI to prepend before each recipient, you can just ' \
      ' give a channel name.'  },
    { type: 'checkbox', name: 'colorize_messages' },
  ]
end

#helpObject


87
88
89
90
91
92
# File 'app/models/project_services/irker_service.rb', line 87

def help
  ' NOTE: Irker does NOT have built-in authentication, which makes it' \
  ' vulnerable to spamming IRC channels if it is hosted outside of a ' \
  ' firewall. Please make sure you run the daemon within a secured network ' \
  ' to prevent abuse. For more details, read: http://www.catb.org/~esr/irker/security.html.'
end

#settingsObject


58
59
60
61
62
# File 'app/models/project_services/irker_service.rb', line 58

def settings
  { server_host: server_host.present? ? server_host : 'localhost',
    server_port: server_port.present? ? server_port : 6659
  }
end

#supported_eventsObject


47
48
49
# File 'app/models/project_services/irker_service.rb', line 47

def supported_events
  %w(push)
end

#titleObject


34
35
36
# File 'app/models/project_services/irker_service.rb', line 34

def title
  'Irker (IRC gateway)'
end

#to_paramObject


43
44
45
# File 'app/models/project_services/irker_service.rb', line 43

def to_param
  'irker'
end