configurable post delay before first post

v1.18.x
barisusakli 10 years ago
parent 9a96458f79
commit 31eccb8e7f

@ -7,6 +7,10 @@
"field": "postDelay",
"value": 10
},
{
"field": "initialPostDelay",
"value": 10
},
{
"field": "minimumPostLength",
"value": 8

@ -27,6 +27,7 @@
"username-too-long": "Username too long",
"user-banned": "User banned",
"user-too-new": "You need to wait %1 seconds before making your first post!",
"no-category": "Category doesn't exist",
"no-topic": "Topic doesn't exist",

@ -56,6 +56,7 @@ module.exports = function(redisClient, module) {
};
module.sortedSetsRemoveRangeByScore = function(keys, min, max, callback) {
callback = callback || function() {};
var multi = redisClient.multi();
for(var i=0; i<keys.length; ++i) {
multi.zremrangebyscore(keys[i], min, max);

@ -151,7 +151,7 @@ var
async.parallel({
userData: function(next) {
User.getUserFields(uid, ['banned', 'lastposttime', 'email', 'email:confirmed'], next);
User.getUserFields(uid, ['banned', 'lastposttime', 'joindate', 'email', 'email:confirmed'], next);
},
exists: function(next) {
db.exists('user:' + uid, next);
@ -181,13 +181,14 @@ var
if (userData.email && parseInt(meta.config.requireEmailConfirmation, 10) === 1 && parseInt(userData['email:confirmed'], 10) !== 1) {
return callback(new Error('[[error:email-not-confirmed]]'));
}
var lastposttime = userData.lastposttime;
if (!lastposttime) {
lastposttime = 0;
var now = Date.now();
if (now - parseInt(userData.joindate, 10) < parseInt(meta.config.initialPostDelay, 10) * 1000) {
return callback(new Error('[[error:user-too-new, ' + meta.config.initialPostDelay + ']]'));
}
if (Date.now() - parseInt(lastposttime, 10) < parseInt(meta.config.postDelay, 10) * 1000) {
var lastposttime = userData.lastposttime || 0;
if (now - parseInt(lastposttime, 10) < parseInt(meta.config.postDelay, 10) * 1000) {
return callback(new Error('[[error:too-many-posts, ' + meta.config.postDelay + ']]'));
}
callback();

Loading…
Cancel
Save