diff --git a/src/threadTools.js b/src/threadTools.js index 77b77aded5..2eabde1db5 100644 --- a/src/threadTools.js +++ b/src/threadTools.js @@ -170,21 +170,25 @@ var RDB = require('./redis.js'), ThreadTools.isFollowing(tid, current_user, function(following) { if (!following) { RDB.sadd('tid:' + tid + ':followers', current_user, function(err, success) { - if (!err) { - callback({ - status: 'ok', - follow: true - }); - } else callback({ status: 'error' }); + if (callback) { + if (!err) { + callback({ + status: 'ok', + follow: true + }); + } else callback({ status: 'error' }); + } }); } else { RDB.srem('tid:' + tid + ':followers', current_user, function(err, success) { - if (!err) { - callback({ - status: 'ok', - follow: false - }); - } else callback({ status: 'error' }); + if (callback) { + if (!err) { + callback({ + status: 'ok', + follow: false + }); + } else callback({ status: 'error' }); + } }); } }); diff --git a/src/topics.js b/src/topics.js index a90e41f4ae..787eade2e4 100644 --- a/src/topics.js +++ b/src/topics.js @@ -353,6 +353,9 @@ marked.setOptions({ if (pid > 0) { RDB.lpush(schema.topics(tid).posts, pid); + // Auto-subscribe the post creator to the newly created topic + threadTools.toggleFollow(tid, uid); + // Notify any users looking at the category that a new topic has arrived Topics.get_topic(tid, uid, function(topicData) { io.sockets.in('category_' + category_id).emit('event:new_topic', topicData);