Просмотр исходного кода

Merge branch 'master' of bitbucket.org:sharelatex/notifications-sharelatex

Henry Oswald 10 лет назад
Родитель
Сommit
5dd890bfc3

+ 2 - 2
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}")

+ 4 - 4
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, messageOpts: true}

+ 3 - 3
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, messageOpts:true}