configurable post delay before first post

This commit is contained in:
barisusakli
2014-09-15 17:01:20 -04:00
parent 9a96458f79
commit 31eccb8e7f
4 changed files with 13 additions and 6 deletions

View File

@@ -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();