2016-01-14 12:35:16 +00:00
|
|
|
Notifications = require("./Notifications")
|
|
|
|
logger = require("logger-sharelatex")
|
2016-01-20 13:57:29 +00:00
|
|
|
metrics = require('metrics-sharelatex')
|
2016-01-14 12:35:16 +00:00
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
getUserNotifications: (req, res)->
|
|
|
|
logger.log user_id: req.params.user_id, "getting user unread notifications"
|
2016-01-20 13:57:29 +00:00
|
|
|
metrics.inc "getUserNotifications"
|
2016-01-14 20:42:48 +00:00
|
|
|
Notifications.getUserNotifications req.params.user_id, (err, notifications)->
|
2016-01-14 12:35:16 +00:00
|
|
|
res.json(notifications)
|
|
|
|
|
|
|
|
addNotification: (req, res)->
|
|
|
|
logger.log user_id: req.params.user_id, notification:req.body, "adding notification"
|
2016-01-20 13:57:29 +00:00
|
|
|
metrics.inc "addNotification"
|
2016-01-14 12:35:16 +00:00
|
|
|
Notifications.addNotification req.params.user_id, req.body, (err, notifications)->
|
2016-01-14 20:42:48 +00:00
|
|
|
if err?
|
|
|
|
res.send 500
|
|
|
|
else
|
|
|
|
res.send()
|
2016-01-14 12:35:16 +00:00
|
|
|
|
2016-02-05 09:38:32 +00:00
|
|
|
removeNotificationId: (req, res)->
|
|
|
|
logger.log user_id: req.params.user_id, notification_id: req.params.notification_id, "mark id notification as read"
|
|
|
|
metrics.inc "removeNotificationId"
|
|
|
|
Notifications.removeNotificationId req.params.user_id, req.params.notification_id, (err, notifications)->
|
|
|
|
res.send()
|
|
|
|
|
|
|
|
removeNotificationKey: (req, res)->
|
|
|
|
logger.log user_id: req.params.user_id, notification_key: req.body.key, "mark key notification as read"
|
|
|
|
metrics.inc "removeNotificationKey"
|
|
|
|
Notifications.removeNotificationKey req.params.user_id, req.body.key, (err, notifications)->
|
2016-01-14 12:35:16 +00:00
|
|
|
res.send()
|