|
|
@@ -1,12 +1,22 @@
|
|
|
NotificationsHandler = require("./NotificationsHandler")
|
|
|
+NotificationsBuilder = require("./NotificationsBuilder")
|
|
|
AuthenticationController = require("../Authentication/AuthenticationController")
|
|
|
+Settings = require 'settings-sharelatex'
|
|
|
logger = require("logger-sharelatex")
|
|
|
_ = require("underscore")
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
getAllUnreadNotifications: (req, res)->
|
|
|
+ ip = req.headers['x-forwarded-for'] ||
|
|
|
+ req.connection.remoteAddress ||
|
|
|
+ req.socket.remoteAddress
|
|
|
user_id = AuthenticationController.getLoggedInUserId(req)
|
|
|
+
|
|
|
+ # in v2 add notifications for matching university IPs
|
|
|
+ if Settings.overleaf?
|
|
|
+ NotificationsBuilder.ipMatcherAffiliation(user_id, ip)
|
|
|
+
|
|
|
NotificationsHandler.getUserNotifications user_id, (err, unreadNotifications)->
|
|
|
unreadNotifications = _.map unreadNotifications, (notification)->
|
|
|
notification.html = req.i18n.translate(notification.templateKey, notification.messageOpts)
|