mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 15:35:47 +01:00
auto-subscribing a user to any topic that they create
This commit is contained in:
@@ -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 (callback) {
|
||||
if (!err) {
|
||||
callback({
|
||||
status: 'ok',
|
||||
follow: true
|
||||
});
|
||||
} else callback({ status: 'error' });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
RDB.srem('tid:' + tid + ':followers', current_user, function(err, success) {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user