2016-01-14 07:35:16 -05:00
|
|
|
Notifications = require("./Notifications")
|
|
|
|
logger = require("logger-sharelatex")
|
2016-01-20 08:57:29 -05:00
|
|
|
metrics = require('metrics-sharelatex')
|
2016-01-14 07:35:16 -05:00
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
getUserNotifications: (req, res)->
|
|
|
|
logger.log user_id: req.params.user_id, "getting user unread notifications"
|
2016-01-20 08:57:29 -05:00
|
|
|
metrics.inc "getUserNotifications"
|
2016-01-14 15:42:48 -05:00
|
|
|
Notifications.getUserNotifications req.params.user_id, (err, notifications)->
|
2016-01-14 07:35:16 -05:00
|
|
|
res.json(notifications)
|
|
|
|
|
|
|
|
addNotification: (req, res)->
|
|
|
|
logger.log user_id: req.params.user_id, notification:req.body, "adding notification"
|
2016-01-20 08:57:29 -05:00
|
|
|
metrics.inc "addNotification"
|
2016-01-14 07:35:16 -05:00
|
|
|
Notifications.addNotification req.params.user_id, req.body, (err, notifications)->
|
2016-01-14 15:42:48 -05:00
|
|
|
if err?
|
|
|
|
res.send 500
|
|
|
|
else
|
|
|
|
res.send()
|
2016-01-14 07:35:16 -05:00
|
|
|
|
2016-02-05 04:38:32 -05: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 07:35:16 -05:00
|
|
|
res.send()
|
2016-08-11 05:01:21 -04:00
|
|
|
|
|
|
|
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()
|