overleaf/services/web/app/coffee/Features/Notifications/NotificationsController.coffee

20 lines
785 B
CoffeeScript
Raw Normal View History

NotificationsHandler = require("./NotificationsHandler")
logger = require("logger-sharelatex")
2016-01-22 15:08:39 -05:00
_ = require("underscore")
module.exports =
getAllUnreadNotifications: (req, res)->
NotificationsHandler.getUserNotifications req.session.user._id, (err, unreadNotifications)->
2016-01-22 15:08:39 -05:00
unreadNotifications = _.map unreadNotifications, (notification)->
notification.html = req.i18n.translate(notification.templateKey, notification.messageOpts)
return notification
res.send(unreadNotifications)
markNotificationAsRead: (req, res)->
user_id = req.session.user._id
notification_id = req.params.notification_id
NotificationsHandler.markAsRead user_id, notification_id, ->
res.send()
logger.log user_id:user_id, notification_id:notification_id, "mark notification as read"