From 6899186600b5e299bdb787597ea937a7a442665b Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sun, 28 Jul 2013 17:10:35 -0400 Subject: [PATCH] Add cache TTL option; fixes --- api.js | 8 ++++---- config.js | 7 ++++++- package.json | 2 +- server.js | 5 +++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/api.js b/api.js index 01dad0ce..03d8ed2c 100644 --- a/api.js +++ b/api.js @@ -286,7 +286,7 @@ module.exports = function (Server) { text: msg }; var api = this; - cfg["nodemailer"].sendMail(mail, function(err, response) { + Server.cfg["nodemailer"].sendMail(mail, function(err, response) { if(err) { Logger.errlog.log("Mail fail: " + err); api.sendJSON(res, { @@ -317,12 +317,12 @@ module.exports = function (Server) { name: info[0], pw: info[1] }); - ActionLog.record(ip, name, "password-recover-success"); - Logger.syslog.log(ip + " recovered password for " + name); + ActionLog.record(ip, info[0], "password-recover-success"); + Logger.syslog.log(ip + " recovered password for " + info[0]); return; } catch(e) { - ActionLog.record(ip, name, "password-recover-failure"); + ActionLog.record(ip, "", "password-recover-failure"); this.sendJSON(res, { success: false, error: e diff --git a/config.js b/config.js index 22c765d8..f313b27c 100644 --- a/config.js +++ b/config.js @@ -39,7 +39,12 @@ var defaults = { } function save(cfg, file) { - fs.writeFile(file, JSON.stringify(cfg, null, 4), function (err) { + var x = {}; + for(var k in cfg) { + if(k !== "nodemailer") + x[k] = cfg[k]; + } + fs.writeFile(file, JSON.stringify(x, null, 4), function (err) { if(err) { Logger.errlog.log("Failed to save config"); Logger.errlog.log(err); diff --git a/package.json b/package.json index e7dde87a..a0814256 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "2.1.2", + "version": "2.1.3", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/server.js b/server.js index fe6c204e..e8eef0b9 100644 --- a/server.js +++ b/server.js @@ -5,7 +5,7 @@ var Logger = require("./logger"); var Channel = require("./channel"); var User = require("./user"); -const VERSION = "2.1.2"; +const VERSION = "2.1.3"; function getIP(req) { var raw = req.connection.remoteAddress; @@ -95,6 +95,7 @@ var Server = { this.app.get("/:thing(*)", function (req, res, next) { var opts = { root: __dirname + "/www", + maxAge: this.cfg["asset-cache-ttl"] } res.sendfile(req.params.thing, opts, function (err) { if(err) { @@ -114,7 +115,7 @@ var Server = { } } }); - }); + }.bind(this)); // fallback this.app.use(function (err, req, res, next) {