Files
overleaf-cep/services/web/app/src/Features/Notifications/NotificationsController.js
Jakob Ackermann d720d6affa Merge pull request #6317 from overleaf/jpa-send-explicit-content-type
[web] send explicit content type in responses

GitOrigin-RevId: d5aeaba57a7d2fc053fbf5adc2299fb46e435341
2022-01-18 09:03:18 +00:00

37 lines
1.0 KiB
JavaScript

const NotificationsHandler = require('./NotificationsHandler')
const SessionManager = require('../Authentication/SessionManager')
const _ = require('underscore')
module.exports = {
getAllUnreadNotifications(req, res, next) {
const userId = SessionManager.getLoggedInUserId(req.session)
NotificationsHandler.getUserNotifications(
userId,
function (err, unreadNotifications) {
if (err) {
return next(err)
}
unreadNotifications = _.map(
unreadNotifications,
function (notification) {
notification.html = req.i18n.translate(
notification.templateKey,
notification.messageOpts
)
return notification
}
)
res.json(unreadNotifications)
}
)
},
markNotificationAsRead(req, res) {
const userId = SessionManager.getLoggedInUserId(req.session)
const { notificationId } = req.params
NotificationsHandler.markAsRead(userId, notificationId, () =>
res.sendStatus(200)
)
},
}