NotificationsController.coffee 846 B

12345678910111213141516171819202122
  1. Notifications = require("./Notifications")
  2. logger = require("logger-sharelatex")
  3. module.exports =
  4. getUserNotifications: (req, res)->
  5. logger.log user_id: req.params.user_id, "getting user unread notifications"
  6. Notifications.getUserNotifications req.params.user_id, (err, notifications)->
  7. res.json(notifications)
  8. addNotification: (req, res)->
  9. logger.log user_id: req.params.user_id, notification:req.body, "adding notification"
  10. Notifications.addNotification req.params.user_id, req.body, (err, notifications)->
  11. if err?
  12. res.send 500
  13. else
  14. res.send()
  15. removeNotification: (req, res)->
  16. logger.log user_id: req.params.user_id, notification_id: req.params.notification_id, "mark notification as read"
  17. Notifications.removeNotification req.params.user_id, req.params.notification_id, (err, notifications)->
  18. res.send()