summaryrefslogtreecommitdiff
path: root/app/models/project_services/hipchat_service.rb
diff options
context:
space:
mode:
authorDominik Sander <git@dsander.de>2015-04-26 20:56:13 +0200
committerDominik Sander <git@dsander.de>2015-04-26 22:00:51 +0200
commit3c3b43b0a0568950b0eb4bdfb6fd27c30686c106 (patch)
tree52fd4044d2f3995ba8ee08948c2febf8a5b70e18 /app/models/project_services/hipchat_service.rb
parentf0c4c51f8323216bd90fb564d6b1bff1f247cf16 (diff)
downloadgitlab-ce-3c3b43b0a0568950b0eb4bdfb6fd27c30686c106.tar.gz
Add notify and color options to HipchatService
When notify is set to true send messages will trigger a notification for all room members. Color changes the background color of the message.
Diffstat (limited to 'app/models/project_services/hipchat_service.rb')
-rw-r--r--app/models/project_services/hipchat_service.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb
index 07520eab5d1..2fa5f0ce71c 100644
--- a/app/models/project_services/hipchat_service.rb
+++ b/app/models/project_services/hipchat_service.rb
@@ -20,7 +20,7 @@
class HipchatService < Service
MAX_COMMITS = 3
- prop_accessor :token, :room, :server
+ prop_accessor :token, :room, :server, :notify, :color
validates :token, presence: true, if: :activated?
def title
@@ -39,6 +39,8 @@ class HipchatService < Service
[
{ type: 'text', name: 'token', placeholder: 'Room token' },
{ type: 'text', name: 'room', placeholder: 'Room name or ID' },
+ { type: 'checkbox', name: 'notify' },
+ { type: 'select', name: 'color', choices: ['yellow', 'red', 'green', 'purple', 'gray', 'random'] },
{ type: 'text', name: 'server',
placeholder: 'Leave blank for default. https://hipchat.example.com' }
]
@@ -52,7 +54,7 @@ class HipchatService < Service
return unless supported_events.include?(data[:object_kind])
message = create_message(data)
return unless message.present?
- gate[room].send('GitLab', message)
+ gate[room].send('GitLab', message, message_options)
end
private
@@ -63,6 +65,10 @@ class HipchatService < Service
@gate ||= HipChat::Client.new(token, options)
end
+ def message_options
+ { notify: notify.present? && notify == '1', color: color || 'yellow' }
+ end
+
def create_message(data)
object_kind = data[:object_kind]