NotificationsController.coffee 785 B

12345678910111213141516171819
  1. NotificationsHandler = require("./NotificationsHandler")
  2. logger = require("logger-sharelatex")
  3. _ = require("underscore")
  4. module.exports =
  5. getAllUnreadNotifications: (req, res)->
  6. NotificationsHandler.getUserNotifications req.session.user._id, (err, unreadNotifications)->
  7. unreadNotifications = _.map unreadNotifications, (notification)->
  8. notification.html = req.i18n.translate(notification.templateKey, notification.messageOpts)
  9. return notification
  10. res.send(unreadNotifications)
  11. markNotificationAsRead: (req, res)->
  12. user_id = req.session.user._id
  13. notification_id = req.params.notification_id
  14. NotificationsHandler.markAsRead user_id, notification_id, ->
  15. res.send()
  16. logger.log user_id:user_id, notification_id:notification_id, "mark notification as read"