This commit is contained in:
Henrique Dias 2016-02-05 07:41:34 -02:00
commit 957e9cd486
5 changed files with 11 additions and 8 deletions

View file

@ -40,6 +40,6 @@ app.get '*', (req, res)->
res.send 404
host = Settings.internal?.notifications?.host || "localhost"
port = Settings.internal?.notifications?.port || 3033
port = Settings.internal?.notifications?.port || 3042
app.listen port, host, ->
logger.info "notifications starting up, listening on #{host}:#{port}"

View file

@ -26,18 +26,21 @@ module.exports =
opts.json = true
request.get opts, (err, res, body)->
if res.statusCode != 200
return cb("status code not 200, its #{res.statusCode}")
e = "status code not 200 #{res.statusCode}"
logger.err err:err, e
return cb(e)
hasNotification = _.some body, (notification)->
notification.key == notification_key and notification.user_id == user_id.toString()
if hasNotification
cb(null,body)
cb(null, body)
else
logger.log body:body, "what is in the body"
logger.log body:body, "got notifications response for health check"
return cb("notification not found in response")
]
async.series jobs, (err, body)->
if err?
logger.err err:err, "error running health check"
return callback(err)
else
notification_id = body[1][0]._id

View file

@ -34,7 +34,7 @@ module.exports =
user_id:ObjectId(user_id)
_id:ObjectId(notification_id)
updateOperation =
"$unset": {templateKey:true}
"$unset": {templateKey:true, messageOpts: true}
db.notifications.update searchOps, updateOperation, callback
removeNotificationKey: (user_id, notification_key, callback)->

View file

@ -1,7 +1,7 @@
module.exports = Settings =
internal:
notifications:
port: 3033
port: 3042
host: "localhost"
mongo:

View file

@ -69,7 +69,7 @@ describe 'Notifications Tests', ->
user_id:ObjectId(user_id)
_id:ObjectId(notification_id)
updateOperation =
"$unset": {templateKey:true}
"$unset": {templateKey:true, messageOpts:true}
@updateStub.calledWith(searchOps, updateOperation).should.equal true
done()
@ -84,4 +84,4 @@ describe 'Notifications Tests', ->
updateOperation =
"$unset": {templateKey:true}
@updateStub.calledWith(searchOps, updateOperation).should.equal true
done()
done()