diff --git a/services/notifications/app/coffee/HealthCheckController.coffee b/services/notifications/app/coffee/HealthCheckController.coffee index a10ecafaa3..b41dc0290a 100644 --- a/services/notifications/app/coffee/HealthCheckController.coffee +++ b/services/notifications/app/coffee/HealthCheckController.coffee @@ -34,11 +34,11 @@ module.exports = cb(null,body) else logger.log body:body, "what is in the body" - cb("notification not found in response") + return cb("notification not found in response") ] async.series jobs, (err, body)-> if err? - callback(err) + return callback(err) else notification_id = body[1][0]._id opts = getOpts("/notification/#{notification_id}") diff --git a/services/notifications/app/coffee/Notifications.coffee b/services/notifications/app/coffee/Notifications.coffee index 9d61452e81..3ae01e8150 100644 --- a/services/notifications/app/coffee/Notifications.coffee +++ b/services/notifications/app/coffee/Notifications.coffee @@ -8,14 +8,14 @@ module.exports = getUserNotifications: (user_id, callback = (err, notifications)->)-> query = - user_id: user_id + user_id: ObjectId(user_id) templateKey: {"$exists":true} db.notifications.find query, (err, notifications)-> callback err, notifications addNotification: (user_id, notification, callback)-> query = - user_id: user_id + user_id: ObjectId(user_id) key: notification.key db.notifications.count query, (err, number)-> if number > 0 @@ -23,7 +23,7 @@ module.exports = callback number else doc = - user_id: user_id + user_id: ObjectId(user_id) key: notification.key messageOpts: notification.messageOpts templateKey: notification.templateKey @@ -31,7 +31,7 @@ module.exports = removeNotification: (user_id, notification_id, callback)-> searchOps = - user_id:user_id + user_id:ObjectId(user_id) _id:ObjectId(notification_id) updateOperation = "$unset": {templateKey:true} diff --git a/services/notifications/test/unit/coffee/NotificationsTests.coffee b/services/notifications/test/unit/coffee/NotificationsTests.coffee index adb58f6a48..aa1755dbf1 100644 --- a/services/notifications/test/unit/coffee/NotificationsTests.coffee +++ b/services/notifications/test/unit/coffee/NotificationsTests.coffee @@ -32,7 +32,7 @@ describe 'creating a user', -> 'settings-sharelatex': {} 'mongojs':@mongojs - @stubbedNotification = {user_id: user_id, key:"notification-key", messageOpts:"some info", templateKey:"template-key"} + @stubbedNotification = {user_id: ObjectId(user_id), key:"notification-key", messageOpts:"some info", templateKey:"template-key"} @stubbedNotificationArray = [@stubbedNotification] describe 'getUserNotifications', -> @@ -40,7 +40,7 @@ describe 'creating a user', -> @findStub.callsArgWith(1, null, @stubbedNotificationArray) @notifications.getUserNotifications user_id, (err, notifications)=> notifications.should.equal @stubbedNotificationArray - @findStub.calledWith({"user_id" : user_id, "templateKey": {"$exists":true}}).should.equal true + @findStub.calledWith({"user_id" : ObjectId(user_id), "templateKey": {"$exists":true}}).should.equal true done() describe 'addNotification', -> @@ -66,7 +66,7 @@ describe 'creating a user', -> @notifications.removeNotification user_id, notification_id, (err)=> searchOps = - user_id:user_id + user_id:ObjectId(user_id) _id:ObjectId(notification_id) updateOperation = "$unset": {templateKey:true}