overleaf/services/notifications/app/coffee/NotificationsController.coffee

27 lines
990 B
CoffeeScript
Raw Normal View History

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-01-14 20:42:48 +00:00
removeNotification: (req, res)->
2016-01-16 20:28:19 +00:00
logger.log user_id: req.params.user_id, notification_id: req.params.notification_id, "mark notification as read"
2016-01-20 13:57:29 +00:00
metrics.inc "removeNotification"
2016-01-14 20:42:48 +00:00
Notifications.removeNotification req.params.user_id, req.params.notification_id, (err, notifications)->
2016-01-14 12:35:16 +00:00
res.send()