mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
configurable post delay before first post
This commit is contained in:
@@ -7,6 +7,10 @@
|
|||||||
"field": "postDelay",
|
"field": "postDelay",
|
||||||
"value": 10
|
"value": 10
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"field": "initialPostDelay",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"field": "minimumPostLength",
|
"field": "minimumPostLength",
|
||||||
"value": 8
|
"value": 8
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
"username-too-long": "Username too long",
|
"username-too-long": "Username too long",
|
||||||
|
|
||||||
"user-banned": "User banned",
|
"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-category": "Category doesn't exist",
|
||||||
"no-topic": "Topic 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) {
|
module.sortedSetsRemoveRangeByScore = function(keys, min, max, callback) {
|
||||||
|
callback = callback || function() {};
|
||||||
var multi = redisClient.multi();
|
var multi = redisClient.multi();
|
||||||
for(var i=0; i<keys.length; ++i) {
|
for(var i=0; i<keys.length; ++i) {
|
||||||
multi.zremrangebyscore(keys[i], min, max);
|
multi.zremrangebyscore(keys[i], min, max);
|
||||||
|
|||||||
13
src/user.js
13
src/user.js
@@ -151,7 +151,7 @@ var
|
|||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
userData: function(next) {
|
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) {
|
exists: function(next) {
|
||||||
db.exists('user:' + uid, 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) {
|
if (userData.email && parseInt(meta.config.requireEmailConfirmation, 10) === 1 && parseInt(userData['email:confirmed'], 10) !== 1) {
|
||||||
return callback(new Error('[[error:email-not-confirmed]]'));
|
return callback(new Error('[[error:email-not-confirmed]]'));
|
||||||
}
|
}
|
||||||
|
var now = Date.now();
|
||||||
var lastposttime = userData.lastposttime;
|
if (now - parseInt(userData.joindate, 10) < parseInt(meta.config.initialPostDelay, 10) * 1000) {
|
||||||
if (!lastposttime) {
|
return callback(new Error('[[error:user-too-new, ' + meta.config.initialPostDelay + ']]'));
|
||||||
lastposttime = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 + ']]'));
|
return callback(new Error('[[error:too-many-posts, ' + meta.config.postDelay + ']]'));
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
|
|||||||
Reference in New Issue
Block a user