2014-08-28 21:55:08 -04:00
|
|
|
config = require '../server_config'
|
|
|
|
request = require 'request'
|
|
|
|
log = require 'winston'
|
|
|
|
|
|
|
|
module.exports.sendHipChatMessage = sendHipChatMessage = (message) ->
|
|
|
|
return unless key = config.hipchatAPIKey
|
2014-11-29 11:43:40 -05:00
|
|
|
return unless config.isProduction
|
2014-08-28 21:55:08 -04:00
|
|
|
roomID = 254598
|
|
|
|
form =
|
|
|
|
color: 'yellow'
|
|
|
|
notify: false
|
|
|
|
message: message
|
|
|
|
messageFormat: 'html'
|
|
|
|
url = "https://api.hipchat.com/v2/room/#{roomID}/notification?auth_token=#{key}"
|
|
|
|
request.post {uri: url, json: form}, (err, res, body) ->
|
2014-08-28 22:39:46 -04:00
|
|
|
return log.error 'Error sending HipChat patch request:', err or body if err or /error/i.test body
|
2014-08-28 21:55:08 -04:00
|
|
|
#log.info "Got HipChat patch response:", body
|
2014-11-24 20:07:29 -05:00
|
|
|
|
|
|
|
module.exports.sendTowerHipChatMessage = sendTowerHipChatMessage = (message) ->
|
2014-11-28 14:37:54 -05:00
|
|
|
secondsFromEpoch = Math.floor(new Date().getTime() / 1000)
|
|
|
|
link = "<a href=\"https://papertrailapp.com/groups/488214/events?time=#{secondsFromEpoch}\">PaperTrail</a>"
|
|
|
|
message = "#{message} #{link}"
|
2014-11-24 20:07:29 -05:00
|
|
|
return unless key = config.hipchatTowerAPIKey
|
2014-11-29 11:43:40 -05:00
|
|
|
return unless config.isProduction
|
2014-11-24 20:07:29 -05:00
|
|
|
roomID = 318356
|
|
|
|
form =
|
|
|
|
color: 'red'
|
|
|
|
notify: true
|
|
|
|
message: message
|
|
|
|
messageFormat: 'html'
|
|
|
|
url = "https://api.hipchat.com/v2/room/#{roomID}/notification?auth_token=#{key}"
|
|
|
|
request.post {uri: url, json: form}, (err, res, body) ->
|
|
|
|
return log.error 'Error sending HipChat Tower message:', err or body if err or /error/i.test body
|