|
|
|
@ -127,6 +127,18 @@ marked.setOptions({
|
|
|
|
|
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) {
|
|
|
|
|
if (pid > 0) {
|
|
|
|
|
RDB.rpush('tid:' + tid + ':posts', pid);
|
|
|
|
@ -182,6 +194,7 @@ marked.setOptions({
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Posts.create = function(uid, tid, content, callback) {
|
|
|
|
@ -194,10 +207,11 @@ marked.setOptions({
|
|
|
|
|
RDB.incr('global:next_post_id', function(err, pid) {
|
|
|
|
|
RDB.handle(err);
|
|
|
|
|
|
|
|
|
|
var timestamp = new Date().getTime();
|
|
|
|
|
// Posts Info
|
|
|
|
|
RDB.set('pid:' + pid + ':content', content);
|
|
|
|
|
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 + ':tid', tid);
|
|
|
|
|
|
|
|
|
@ -225,6 +239,7 @@ marked.setOptions({
|
|
|
|
|
RDB.lpush('uid:' + uid + ':posts', pid);
|
|
|
|
|
|
|
|
|
|
user.incrementUserFieldBy(uid, 'postcount', 1);
|
|
|
|
|
user.setUserField(uid, 'lastposttime', timestamp);
|
|
|
|
|
|
|
|
|
|
if (callback)
|
|
|
|
|
callback(pid);
|
|
|
|
|