mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
post every x seconds added it x to config
This commit is contained in:
@@ -59,7 +59,8 @@ var config = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
"show_motd": true,
|
"show_motd": true,
|
||||||
"motd": undefined
|
"motd": undefined,
|
||||||
|
"post_delay" : 10000
|
||||||
}
|
}
|
||||||
|
|
||||||
config.url = config.base_url + (config.use_port ? ':' + config.port : '') + '/';
|
config.url = config.base_url + (config.use_port ? ':' + config.port : '') + '/';
|
||||||
|
|||||||
17
src/posts.js
17
src/posts.js
@@ -127,6 +127,18 @@ marked.setOptions({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.getUserField(uid, 'lastposttime', function(lastposttime) {
|
||||||
|
|
||||||
|
if(new Date().getTime() - lastposttime < config.post_delay) {
|
||||||
|
socket.emit('event:alert', {
|
||||||
|
title: 'Too many posts!',
|
||||||
|
message: 'You can only post every '+ (config.post_delay / 1000) + ' seconds.',
|
||||||
|
type: 'error',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Posts.create(uid, tid, content, function(pid) {
|
Posts.create(uid, tid, content, function(pid) {
|
||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
RDB.rpush('tid:' + tid + ':posts', pid);
|
RDB.rpush('tid:' + tid + ':posts', pid);
|
||||||
@@ -182,6 +194,7 @@ marked.setOptions({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Posts.create = function(uid, tid, content, callback) {
|
Posts.create = function(uid, tid, content, callback) {
|
||||||
@@ -194,10 +207,11 @@ marked.setOptions({
|
|||||||
RDB.incr('global:next_post_id', function(err, pid) {
|
RDB.incr('global:next_post_id', function(err, pid) {
|
||||||
RDB.handle(err);
|
RDB.handle(err);
|
||||||
|
|
||||||
|
var timestamp = new Date().getTime();
|
||||||
// Posts Info
|
// Posts Info
|
||||||
RDB.set('pid:' + pid + ':content', content);
|
RDB.set('pid:' + pid + ':content', content);
|
||||||
RDB.set('pid:' + pid + ':uid', uid);
|
RDB.set('pid:' + pid + ':uid', uid);
|
||||||
RDB.set('pid:' + pid + ':timestamp', new Date().getTime());
|
RDB.set('pid:' + pid + ':timestamp', timestamp);
|
||||||
RDB.set('pid:' + pid + ':rep', 0);
|
RDB.set('pid:' + pid + ':rep', 0);
|
||||||
RDB.set('pid:' + pid + ':tid', tid);
|
RDB.set('pid:' + pid + ':tid', tid);
|
||||||
|
|
||||||
@@ -225,6 +239,7 @@ marked.setOptions({
|
|||||||
RDB.lpush('uid:' + uid + ':posts', pid);
|
RDB.lpush('uid:' + uid + ':posts', pid);
|
||||||
|
|
||||||
user.incrementUserFieldBy(uid, 'postcount', 1);
|
user.incrementUserFieldBy(uid, 'postcount', 1);
|
||||||
|
user.setUserField(uid, 'lastposttime', timestamp);
|
||||||
|
|
||||||
if (callback)
|
if (callback)
|
||||||
callback(pid);
|
callback(pid);
|
||||||
|
|||||||
@@ -295,6 +295,18 @@ marked.setOptions({
|
|||||||
return; // for now, until anon code is written.
|
return; // for now, until anon code is written.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.getUserField(uid, 'lastposttime', function(lastposttime) {
|
||||||
|
|
||||||
|
if(new Date().getTime() - lastposttime < config.post_delay) {
|
||||||
|
socket.emit('event:alert', {
|
||||||
|
title: 'Too many posts!',
|
||||||
|
message: 'You can only post every '+ (config.post_delay / 1000) + ' seconds.',
|
||||||
|
type: 'error',
|
||||||
|
timeout: 2000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RDB.incr('global:next_topic_id', function(err, tid) {
|
RDB.incr('global:next_topic_id', function(err, tid) {
|
||||||
RDB.handle(err);
|
RDB.handle(err);
|
||||||
|
|
||||||
@@ -358,6 +370,7 @@ marked.setOptions({
|
|||||||
|
|
||||||
RDB.incr('cid:' + category_id + ':topiccount');
|
RDB.incr('cid:' + category_id + ':topiccount');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}(exports));
|
}(exports));
|
||||||
@@ -288,7 +288,8 @@ var config = require('../config.js'),
|
|||||||
'gravatarpicture' : gravatar,
|
'gravatarpicture' : gravatar,
|
||||||
'uploadedpicture': '',
|
'uploadedpicture': '',
|
||||||
'reputation': 0,
|
'reputation': 0,
|
||||||
'postcount': 0
|
'postcount': 0,
|
||||||
|
'lastposttime': 0
|
||||||
});
|
});
|
||||||
|
|
||||||
RDB.set('username:' + username + ':uid', uid);
|
RDB.set('username:' + username + ':uid', uid);
|
||||||
|
|||||||
Reference in New Issue
Block a user