closes #365, allow guest posting. enabled from admin/settings, defaults to disabled

This commit is contained in:
Baris Usakli
2013-11-01 13:04:15 -04:00
parent e8c4bda984
commit 04ed1df0ef
7 changed files with 53 additions and 44 deletions

View File

@@ -287,41 +287,34 @@ var RDB = require('./redis.js'),
return;
}
user.getUserField(uid, 'lastposttime', function(lastposttime) {
if (Date.now() - lastposttime < meta.config.postDelay) {
callback(new Error('too-many-posts'), null);
return;
Posts.create(uid, tid, content, function(postData) {
if (postData) {
topics.markUnRead(tid);
Posts.get_cid_by_pid(postData.pid, function(cid) {
RDB.del('cid:' + cid + ':read_by_uid', function(err, data) {
topics.markAsRead(tid, uid);
});
});
threadTools.notifyFollowers(tid, uid);
Posts.addUserInfoToPost(postData, function() {
var socketData = {
posts: [postData]
};
io.sockets.in('topic_' + tid).emit('event:new_post', socketData);
io.sockets.in('recent_posts').emit('event:new_post', socketData);
io.sockets.in('user/' + uid).emit('event:new_post', socketData);
});
callback(null, 'Reply successful');
} else {
callback(new Error('reply-error'), null);
}
Posts.create(uid, tid, content, function(postData) {
if (postData) {
topics.markUnRead(tid);
Posts.get_cid_by_pid(postData.pid, function(cid) {
RDB.del('cid:' + cid + ':read_by_uid', function(err, data) {
topics.markAsRead(tid, uid);
});
});
threadTools.notify_followers(tid, uid);
Posts.addUserInfoToPost(postData, function() {
var socketData = {
posts: [postData]
};
io.sockets.in('topic_' + tid).emit('event:new_post', socketData);
io.sockets.in('recent_posts').emit('event:new_post', socketData);
io.sockets.in('user/' + uid).emit('event:new_post', socketData);
});
callback(null, 'Reply successful');
} else {
callback(new Error('reply-error'), null);
}
});
});
};
}
Posts.create = function(uid, tid, content, callback) {
if (uid === null) {