mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Mark Notification as read by key alone
This commit is contained in:
parent
3cec6affab
commit
826295167f
3 changed files with 27 additions and 2 deletions
|
@ -3,6 +3,8 @@ NotificationsHandler = require("./NotificationsHandler")
|
|||
|
||||
module.exports =
|
||||
|
||||
# Note: notification keys should be url-safe
|
||||
|
||||
groupPlan: (user, licence)->
|
||||
key : "join-sub-#{licence.subscription_id}"
|
||||
create: (callback = ->)->
|
||||
|
@ -26,4 +28,4 @@ module.exports =
|
|||
logger.log {user_id: user._id, project_id: project._id, invite_id: invite._id, key: @key}, "creating project invite notification for user"
|
||||
NotificationsHandler.createNotification user._id, @key, "notification_project_invite", messageOpts, callback
|
||||
read: (callback=()->) ->
|
||||
NotificationsHandler.markAsReadWithKey user._id, @key, callback
|
||||
NotificationsHandler.markAsReadByKeyOnly @key, callback
|
||||
|
|
|
@ -61,3 +61,13 @@ module.exports =
|
|||
timeout:oneSecond
|
||||
logger.log user_id:user_id, notification_id:notification_id, "sending mark notification as read to notifications api"
|
||||
makeRequest opts, callback
|
||||
|
||||
# removes notification by key, without regard for user_id,
|
||||
# should not be exposed to user via ui/router
|
||||
markAsReadByKeyOnly: (key, callback)->
|
||||
opts =
|
||||
uri: "#{settings.apis.notifications?.url}/notification/key/#{key}"
|
||||
method: "DELETE"
|
||||
timeout: oneSecond
|
||||
logger.log {key:key}, "sending mark notification as read with key-only to notifications api"
|
||||
makeRequest opts, callback
|
||||
|
|
|
@ -68,4 +68,17 @@ describe 'NotificationsHandler', ->
|
|||
args.timeout.should.equal 1000
|
||||
expectedJson = {key:@key, templateKey:@templateKey, messageOpts:@messageOpts}
|
||||
assert.deepEqual(args.json, expectedJson)
|
||||
done()
|
||||
done()
|
||||
|
||||
describe "markAsReadByKeyOnly", ->
|
||||
beforeEach ->
|
||||
@key = "some key here"
|
||||
|
||||
it 'should send a delete request when a delete has been received to mark a notification', (done)->
|
||||
@handler.markAsReadByKeyOnly @key, =>
|
||||
opts =
|
||||
uri: "#{notificationUrl}/notification/key/#{@key}"
|
||||
timeout:1000
|
||||
method: "DELETE"
|
||||
@request.calledWith(opts).should.equal true
|
||||
done()
|
||||
|
|
Loading…
Reference in a new issue