diff --git a/app/views/editor/level/thangs/ThangsTabView.coffee b/app/views/editor/level/thangs/ThangsTabView.coffee index 3745e2f8b..0834f7c25 100644 --- a/app/views/editor/level/thangs/ThangsTabView.coffee +++ b/app/views/editor/level/thangs/ThangsTabView.coffee @@ -313,7 +313,7 @@ module.exports = class ThangsTabView extends CocoView createEssentialComponents: (defaultComponents) -> physicalConfig = {pos: {x: 10, y: 10, z: 1}} if physicalOriginal = _.find(defaultComponents ? [], original: componentOriginals['physics.Physical']) - physicalConfig.pos.z = physicalOriginal.config.pos.z # Get the z right + physicalConfig.pos.z = physicalOriginal.config?.pos?.z ? 1 # Get the z right console.log physicalOriginal, defaultComponents, componentOriginals['physics.Physical'], physicalConfig [ {original: componentOriginals['existence.Exists'], majorVersion: 0, config: {}} diff --git a/server/commons/Handler.coffee b/server/commons/Handler.coffee index 6b1c110a6..aea9810c1 100644 --- a/server/commons/Handler.coffee +++ b/server/commons/Handler.coffee @@ -6,6 +6,7 @@ log = require 'winston' Patch = require '../patches/Patch' User = require '../users/User' sendwithus = require '../sendwithus' +hipchat = require '../hipchat' PROJECT = {original: 1, name: 1, version: 1, description: 1, slug: 1, kind: 1, created: 1, permissions: 1} FETCH_LIMIT = 300 @@ -370,6 +371,8 @@ module.exports = class Handler parentDocument.makeNewMajorVersion(updatedObject, done) notifyWatchersOfChange: (editor, changedDocument, editPath) -> + docLink = "http://codecombat.com#{editPath}" + @sendChangedHipChatMessage creator: editor, target: changedDocument, docLink: docLink watchers = changedDocument.get('watchers') or [] watchers = (w for w in watchers when not w.equals(editor.get('_id'))) return unless watchers.length @@ -390,9 +393,20 @@ module.exports = class Handler commit_message: changedDocument.get('commitMessage') sendwithus.api.send context, (err, result) -> + sendChangedHipChatMessage: (options) -> + message = "#{options.creator.get('name')} saved a change to #{options.target.get('name')}: #{options.target.get('commitMessage')}" + hipchat.sendHipChatMessage message + makeNewInstance: (req) -> model = new @modelClass({}) - model.set 'watchers', [req.user.get('_id')] if @modelClass.schema.is_patchable + if @modelClass.schema.is_patchable + watchers = [req.user.get('_id')] + if req.user.isAdmin() # https://github.com/codecombat/codecombat/issues/1105 + nick = mongoose.Types.ObjectId('512ef4805a67a8c507000001') + scott = mongoose.Types.ObjectId('5162fab9c92b4c751e000274') + watchers.push nick unless _.find watchers, (id) -> id.equals nick + watchers.push scott unless _.find watchers, (id) -> id.equals scott + model.set 'watchers', watchers model validateDocumentInput: (input) -> diff --git a/server/delighted.coffee b/server/delighted.coffee index 81fd5503e..78062f303 100644 --- a/server/delighted.coffee +++ b/server/delighted.coffee @@ -22,5 +22,5 @@ module.exports.addDelightedUser = addDelightedUser = (user) -> gender: user.get('gender') lastLevel: user.get('lastLevel') request.post {uri: "https://#{key}:@api.delightedapp.com/v1/people.json", form: form}, (err, res, body) -> - return log.error 'Error sending Delighted request:', err or body if err or /error/.test body + return log.error 'Error sending Delighted request:', err or body if err or /error/i.test body #log.info "Got DelightedApp response: #{body}" diff --git a/server/hipchat.coffee b/server/hipchat.coffee index 6ca43205d..e85b21c1f 100644 --- a/server/hipchat.coffee +++ b/server/hipchat.coffee @@ -12,5 +12,5 @@ module.exports.sendHipChatMessage = sendHipChatMessage = (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 + return log.error 'Error sending HipChat patch request:', err or body if err or /error/i.test body #log.info "Got HipChat patch response:", body