diff --git a/src/posts.js b/src/posts.js index 30bd219d3b..07cf4f8a93 100644 --- a/src/posts.js +++ b/src/posts.js @@ -265,7 +265,7 @@ var RDB = require('./redis.js'), Posts.emitTooManyPostsAlert = function(socket) { socket.emit('event:alert', { title: 'Too many posts!', - message: 'You can only post every ' + meta.config.postDelay / 1000 + ' seconds.', + message: 'You can only post every ' + meta.config.postDelay + ' seconds.', type: 'danger', timeout: 2000 }); diff --git a/src/topics.js b/src/topics.js index 7e21f07d78..cc383493a9 100644 --- a/src/topics.js +++ b/src/topics.js @@ -685,7 +685,7 @@ var RDB = require('./redis.js'), user.getUserField(uid, 'lastposttime', function(err, lastposttime) { if (err) lastposttime = 0; - if (Date.now() - lastposttime < meta.config.postDelay) { + if (Date.now() - lastposttime < meta.config.postDelay * 1000) { callback(new Error('too-many-posts'), null); return; } diff --git a/src/upgrade.js b/src/upgrade.js index 18a6b3c326..f5a4789b5b 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -81,6 +81,19 @@ Upgrade.upgrade = function() { next(); } }); + }, + function(next) { + RDB.hget('config', 'postDelay', function(err, postDelay) { + if(parseInt(postDelay, 10) > 10) { + RDB.hset('config', 'postDelay', 10, function(err, success) { + winston.info('[2013/11/11] Updated postDelay to 10 seconds.'); + next(); + }); + } else { + winston.info('[2013/11/11] Update to postDelay skipped.'); + next(); + } + }); } // Add new schema updates here ], function(err) { diff --git a/src/websockets.js b/src/websockets.js index aa650d4173..cb01f26d0e 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -157,7 +157,7 @@ module.exports.init = function(io) { for (var i = 0; i < clients.length; ++i) { var hs = clients[i].handshake; - if (hs && clients[i].state.user.uid === 0) { + if (hs && clients[i].state && clients[i].state.user.uid === 0) { ++anonCount; } } @@ -407,7 +407,7 @@ module.exports.init = function(io) { return; } - if (Date.now() - lastPostTime < meta.config.postDelay) { + if (Date.now() - lastPostTime < meta.config.postDelay * 1000) { posts.emitTooManyPostsAlert(socket); return; }