mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge branch 'master' of bitbucket.org:sharelatex/notifications-sharelatex
This commit is contained in:
commit
5dd890bfc3
3 changed files with 9 additions and 9 deletions
|
@ -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}")
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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}
|
||||
|
|
Loading…
Reference in a new issue