Class: HipchatService
- Inherits:
-
Service
show all
- Includes:
- ActionView::Helpers::SanitizeHelper
- Defined in:
- app/models/project_services/hipchat_service.rb
Constant Summary
collapse
- MAX_COMMITS =
3
- HIPCHAT_ALLOWED_TAGS =
%w[
a b i strong em br img pre code
table th tr td caption colgroup col thead tbody tfoot
ul ol li dl dt dd
].freeze
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 inherited from Service
#activated?, #api_field_names, #async_execute, available_services_names, available_services_types, boolean_accessor, build_from_integration, #can_test?, #category, #configurable_event_actions, #configurable_events, default_integration, dev_services_names, #editable?, #event_channel_names, event_description, #event_field, event_names, #event_names, find_or_create_templates, find_or_initialize_all, find_or_initialize_integration, #global_fields, #help, 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, #supports_data_fields?, #to_data_fields_hash, #to_param, #to_service_hash, #updated_properties
#build_message, #log_error, #log_info, #logger
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
.supported_events ⇒ Object
50
51
52
|
# File 'app/models/project_services/hipchat_service.rb', line 50
def self.supported_events
%w(push issue confidential_issue merge_request note confidential_note tag_push pipeline)
end
|
.to_param ⇒ Object
32
33
34
|
# File 'app/models/project_services/hipchat_service.rb', line 32
def self.to_param
'hipchat'
end
|
Instance Method Details
#description ⇒ Object
28
29
30
|
# File 'app/models/project_services/hipchat_service.rb', line 28
def description
'Private group chat and IM'
end
|
#execute(data) ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'app/models/project_services/hipchat_service.rb', line 54
def execute(data)
return unless supported_events.include?(data[:object_kind])
message = create_message(data)
return unless message.present?
gate[room].send('GitLab', message, message_options(data)) end
|
#fields ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/models/project_services/hipchat_service.rb', line 36
def fields
[
{ type: 'text', name: 'token', placeholder: 'Room token', required: true },
{ type: 'text', name: 'room', placeholder: 'Room name or ID' },
{ type: 'checkbox', name: 'notify' },
{ type: 'select', name: 'color', choices: %w(yellow red green purple gray random) },
{ type: 'text', name: 'api_version',
placeholder: 'Leave blank for default (v2)' },
{ type: 'text', name: 'server',
placeholder: 'Leave blank for default. https://hipchat.example.com' },
{ type: 'checkbox', name: 'notify_only_broken_pipelines' }
]
end
|
#initialize_properties ⇒ Object
17
18
19
20
21
22
|
# File 'app/models/project_services/hipchat_service.rb', line 17
def initialize_properties
if properties.nil?
self.properties = {}
self.notify_only_broken_pipelines = true
end
end
|
#test(data) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'app/models/project_services/hipchat_service.rb', line 63
def test(data)
begin
result = execute(data)
rescue StandardError => error
return { success: false, result: error }
end
{ success: true, result: result }
end
|
#title ⇒ Object
24
25
26
|
# File 'app/models/project_services/hipchat_service.rb', line 24
def title
'HipChat'
end
|