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

22 lines
939 B
CoffeeScript
Raw Normal View History

NotificationsHandler = require("./NotificationsHandler")
2016-09-05 14:58:31 +00:00
AuthenticationController = require("../Authentication/AuthenticationController")
logger = require("logger-sharelatex")
2016-01-22 20:08:39 +00:00
_ = require("underscore")
module.exports =
getAllUnreadNotifications: (req, res)->
2016-09-05 14:58:31 +00:00
user_id = AuthenticationController.getLoggedInUserId(req)
NotificationsHandler.getUserNotifications user_id, (err, unreadNotifications)->
unreadNotifications = _.map unreadNotifications, (notification)->
2016-01-22 20:08:39 +00:00
notification.html = req.i18n.translate(notification.templateKey, notification.messageOpts)
return notification
res.send(unreadNotifications)
markNotificationAsRead: (req, res)->
2016-09-05 14:58:31 +00:00
user_id = AuthenticationController.getLoggedInUserId(req)
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"