mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-01 21:31:36 +02:00
Remove `underscore` in monorepo GitOrigin-RevId: fd3b92e3e8a940a7a086669232102320c34a89e2
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
const NotificationsHandler = require('./NotificationsHandler')
|
|
const SessionManager = require('../Authentication/SessionManager')
|
|
const _ = require('lodash')
|
|
|
|
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)
|
|
)
|
|
},
|
|
}
|