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