2016-11-11 17:03:01 +00:00
|
|
|
AnnouncementsHandler = require("./AnnouncementsHandler")
|
|
|
|
AuthenticationController = require("../Authentication/AuthenticationController")
|
|
|
|
logger = require("logger-sharelatex")
|
2016-11-25 11:59:29 +00:00
|
|
|
settings = require("settings-sharelatex")
|
2016-11-11 17:03:01 +00:00
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
getUndreadAnnouncements: (req, res, next)->
|
2016-11-11 17:15:36 +00:00
|
|
|
if !settings?.apis?.analytics?.url? or !settings.apis.blog.url?
|
|
|
|
return res.json []
|
|
|
|
|
2017-01-24 16:03:05 +00:00
|
|
|
user = AuthenticationController.getSessionUser(req)
|
|
|
|
logger.log {user_id:user?._id}, "getting unread announcements"
|
|
|
|
AnnouncementsHandler.getUnreadAnnouncements user, (err, announcements)->
|
2016-11-11 17:03:01 +00:00
|
|
|
if err?
|
2017-01-25 10:38:39 +00:00
|
|
|
logger.err {err:err, user_id:user._id}, "unable to get unread announcements"
|
2016-11-11 17:03:01 +00:00
|
|
|
next(err)
|
|
|
|
else
|
|
|
|
res.json announcements
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|