mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-26 00:58:00 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
1d08a5b431
4 changed files with 29 additions and 3 deletions
|
@ -88,6 +88,7 @@ class AudioPlayer extends CocoClass
|
||||||
@soundsToPlayWhenLoaded[name] = volume
|
@soundsToPlayWhenLoaded[name] = volume
|
||||||
|
|
||||||
playSound: (name, volume=1, delay=0, pos=null) ->
|
playSound: (name, volume=1, delay=0, pos=null) ->
|
||||||
|
return console.error 'Trying to play empty sound?' unless name
|
||||||
audioOptions = {volume: (me.get('volume') ? 1) * volume, delay: delay}
|
audioOptions = {volume: (me.get('volume') ? 1) * volume, delay: delay}
|
||||||
filename = if _.string.startsWith(name, '/file/') then name else '/file/' + name
|
filename = if _.string.startsWith(name, '/file/') then name else '/file/' + name
|
||||||
unless (filename of cache) and createjs.Sound.loadComplete filename
|
unless (filename of cache) and createjs.Sound.loadComplete filename
|
||||||
|
|
16
server/hipchat.coffee
Normal file
16
server/hipchat.coffee
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
config = require '../server_config'
|
||||||
|
request = require 'request'
|
||||||
|
log = require 'winston'
|
||||||
|
|
||||||
|
module.exports.sendHipChatMessage = sendHipChatMessage = (message) ->
|
||||||
|
return unless key = config.hipchatAPIKey
|
||||||
|
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) ->
|
||||||
|
return log.error 'Error sending HipChat patch request:', err or body if err or /error/.test body
|
||||||
|
#log.info "Got HipChat patch response:", body
|
|
@ -6,6 +6,7 @@ schema = require '../../app/schemas/models/patch'
|
||||||
mongoose = require 'mongoose'
|
mongoose = require 'mongoose'
|
||||||
log = require 'winston'
|
log = require 'winston'
|
||||||
sendwithus = require '../sendwithus'
|
sendwithus = require '../sendwithus'
|
||||||
|
hipchat = require '../hipchat'
|
||||||
|
|
||||||
PatchHandler = class PatchHandler extends Handler
|
PatchHandler = class PatchHandler extends Handler
|
||||||
modelClass: Patch
|
modelClass: Patch
|
||||||
|
@ -75,14 +76,16 @@ PatchHandler = class PatchHandler extends Handler
|
||||||
onPostSuccess: (req, doc) ->
|
onPostSuccess: (req, doc) ->
|
||||||
log.error 'Error sending patch created: could not find the loaded target on the patch object.' unless doc.targetLoaded
|
log.error 'Error sending patch created: could not find the loaded target on the patch object.' unless doc.targetLoaded
|
||||||
return unless doc.targetLoaded
|
return unless doc.targetLoaded
|
||||||
|
docLink = "http://codecombat.com#{req.headers['x-current-path']}"
|
||||||
|
@sendPatchCreatedHipChatMessage creator: req.user, patch: doc, target: doc.targetLoaded, docLink: docLink
|
||||||
watchers = doc.targetLoaded.get('watchers') or []
|
watchers = doc.targetLoaded.get('watchers') or []
|
||||||
watchers = (w for w in watchers when not w.equals(req.user.get('_id')))
|
watchers = (w for w in watchers when not w.equals(req.user.get('_id')))
|
||||||
return unless watchers?.length
|
return unless watchers?.length
|
||||||
User.find({_id: {$in: watchers}}).select({email: 1, name: 1}).exec (err, watchers) =>
|
User.find({_id: {$in: watchers}}).select({email: 1, name: 1}).exec (err, watchers) =>
|
||||||
for watcher in watchers
|
for watcher in watchers
|
||||||
@sendPatchCreatedEmail req.user, watcher, doc, doc.targetLoaded, req.headers['x-current-path']
|
@sendPatchCreatedEmail req.user, watcher, doc, doc.targetLoaded, docLink
|
||||||
|
|
||||||
sendPatchCreatedEmail: (patchCreator, watcher, patch, target, editPath) ->
|
sendPatchCreatedEmail: (patchCreator, watcher, patch, target, docLink) ->
|
||||||
# return if watcher._id is patchCreator._id
|
# return if watcher._id is patchCreator._id
|
||||||
context =
|
context =
|
||||||
email_id: sendwithus.templates.patch_created
|
email_id: sendwithus.templates.patch_created
|
||||||
|
@ -92,8 +95,12 @@ PatchHandler = class PatchHandler extends Handler
|
||||||
email_data:
|
email_data:
|
||||||
doc_name: target.get('name') or '???'
|
doc_name: target.get('name') or '???'
|
||||||
submitter_name: patchCreator.get('name') or '???'
|
submitter_name: patchCreator.get('name') or '???'
|
||||||
doc_link: "http://codecombat.com#{editPath}"
|
doc_link: docLink
|
||||||
commit_message: patch.get('commitMessage')
|
commit_message: patch.get('commitMessage')
|
||||||
sendwithus.api.send context, (err, result) ->
|
sendwithus.api.send context, (err, result) ->
|
||||||
|
|
||||||
|
sendPatchCreatedHipChatMessage: (options) ->
|
||||||
|
message = "#{options.creator.get('name')} submitted a patch to <a href=\"#{options.docLink}\">#{options.target.get('name')}</a>: #{options.patch.get('commitMessage')}"
|
||||||
|
hipchat.sendHipChatMessage message
|
||||||
|
|
||||||
module.exports = new PatchHandler()
|
module.exports = new PatchHandler()
|
||||||
|
|
|
@ -41,6 +41,8 @@ config.mail =
|
||||||
cronHandlerPublicIP: process.env.COCO_CRON_PUBLIC_IP or ''
|
cronHandlerPublicIP: process.env.COCO_CRON_PUBLIC_IP or ''
|
||||||
cronHandlerPrivateIP: process.env.COCO_CRON_PRIVATE_IP or ''
|
cronHandlerPrivateIP: process.env.COCO_CRON_PRIVATE_IP or ''
|
||||||
|
|
||||||
|
config.hipchatAPIKey = process.env.COCO_HIPCHAT_API_KEY or ''
|
||||||
|
|
||||||
config.queue =
|
config.queue =
|
||||||
accessKeyId: process.env.COCO_AWS_ACCESS_KEY_ID or ''
|
accessKeyId: process.env.COCO_AWS_ACCESS_KEY_ID or ''
|
||||||
secretAccessKey: process.env.COCO_AWS_SECRET_ACCESS_KEY or ''
|
secretAccessKey: process.env.COCO_AWS_SECRET_ACCESS_KEY or ''
|
||||||
|
|
Loading…
Reference in a new issue