mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Add an endpoint to remove a notification by its key alone
This commit is contained in:
parent
197ee9f4d9
commit
fc78bfe86c
5 changed files with 51 additions and 14 deletions
|
@ -24,6 +24,7 @@ app.post '/user/:user_id', controller.addNotification
|
|||
app.get '/user/:user_id', controller.getUserNotifications
|
||||
app.del '/user/:user_id/notification/:notification_id', controller.removeNotificationId
|
||||
app.del '/user/:user_id', controller.removeNotificationKey
|
||||
app.del '/notification/key/:key', controller.removeNotificationByKeyOnly
|
||||
|
||||
app.get '/status', (req, res)->
|
||||
res.send('notifications sharelatex up')
|
||||
|
|
|
@ -44,3 +44,10 @@ module.exports =
|
|||
updateOperation =
|
||||
"$unset": {templateKey:true}
|
||||
db.notifications.update searchOps, updateOperation, callback
|
||||
|
||||
removeNotificationByKeyOnly: (notification_key, callback)->
|
||||
searchOps =
|
||||
key: notification_key
|
||||
updateOperation =
|
||||
"$unset": {templateKey:true}
|
||||
db.notifications.update searchOps, updateOperation, callback
|
||||
|
|
|
@ -30,3 +30,10 @@ module.exports =
|
|||
metrics.inc "removeNotificationKey"
|
||||
Notifications.removeNotificationKey req.params.user_id, req.body.key, (err, notifications)->
|
||||
res.send()
|
||||
|
||||
removeNotificationByKeyOnly: (req, res)->
|
||||
notification_key = req.params.key
|
||||
logger.log {notification_key}, "mark notification as read by key only"
|
||||
metrics.inc "removeNotificationKey"
|
||||
Notifications.removeNotificationByKeyOnly notification_key, (err, notifications)->
|
||||
res.send()
|
||||
|
|
|
@ -64,3 +64,13 @@ describe 'Notifications Controller', ->
|
|||
@controller.removeNotificationKey req, send:(result)=>
|
||||
@notifications.removeNotificationKey.calledWith(user_id, notification_key).should.equal true
|
||||
done()
|
||||
|
||||
describe "removeNotificationByKeyOnly", ->
|
||||
it "should tell the notifications to mark the notification Key as read", (done)->
|
||||
@notifications.removeNotificationByKeyOnly = sinon.stub().callsArgWith(1)
|
||||
req =
|
||||
params:
|
||||
key: notification_key
|
||||
@controller.removeNotificationByKeyOnly req, send:(result)=>
|
||||
@notifications.removeNotificationByKeyOnly.calledWith(notification_key).should.equal true
|
||||
done()
|
||||
|
|
|
@ -85,3 +85,15 @@ describe 'Notifications Tests', ->
|
|||
"$unset": {templateKey:true}
|
||||
@updateStub.calledWith(searchOps, updateOperation).should.equal true
|
||||
done()
|
||||
|
||||
describe 'removeNotificationByKeyOnly', ->
|
||||
it 'should mark the notification key as read', (done)->
|
||||
@updateStub.callsArgWith(2, null)
|
||||
|
||||
@notifications.removeNotificationByKeyOnly notification_key, (err)=>
|
||||
searchOps =
|
||||
key: notification_key
|
||||
updateOperation =
|
||||
"$unset": {templateKey:true}
|
||||
@updateStub.calledWith(searchOps, updateOperation).should.equal true
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue