mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-30 22:00:49 +00:00
63b84d3724
also up timeout
23 lines
744 B
CoffeeScript
23 lines
744 B
CoffeeScript
request = require "request"
|
|
settings = require "settings-sharelatex"
|
|
_ = require("underscore")
|
|
logger = require "logger-sharelatex"
|
|
|
|
module.exports = BlogHandler =
|
|
|
|
getLatestAnnouncements: (callback)->
|
|
blogUrl = "#{settings.apis.blog.url}/blog/latestannouncements.json"
|
|
opts =
|
|
url:blogUrl
|
|
json:true
|
|
timeout:1000
|
|
request.get opts, (err, res, announcements)->
|
|
if err?
|
|
return callback err
|
|
if res.statusCode != 200
|
|
return callback("blog announcement returned non 200")
|
|
logger.log announcementsLength: announcements?.length, "announcements returned"
|
|
announcements = _.map announcements, (announcement)->
|
|
announcement.date = new Date(announcement.date)
|
|
return announcement
|
|
callback(err, announcements)
|