mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
closes #491, added check to prevent crash in getAnonUserCount
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user