auto-subscribing a user to any topic that they create

v1.18.x
Julian Lam 12 years ago
parent 882b9a917f
commit 89effc5454

@ -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' });
}
});
}
});

@ -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);

Loading…
Cancel
Save