auto-subscribing a user to any topic that they create

This commit is contained in:
Julian Lam
2013-06-07 14:41:21 -04:00
parent 882b9a917f
commit 89effc5454
2 changed files with 19 additions and 12 deletions

View File

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