mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 23:45:45 +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) {
|
ThreadTools.isFollowing(tid, current_user, function(following) {
|
||||||
if (!following) {
|
if (!following) {
|
||||||
RDB.sadd('tid:' + tid + ':followers', current_user, function(err, success) {
|
RDB.sadd('tid:' + tid + ':followers', current_user, function(err, success) {
|
||||||
if (!err) {
|
if (callback) {
|
||||||
callback({
|
if (!err) {
|
||||||
status: 'ok',
|
callback({
|
||||||
follow: true
|
status: 'ok',
|
||||||
});
|
follow: true
|
||||||
} else callback({ status: 'error' });
|
});
|
||||||
|
} else callback({ status: 'error' });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
RDB.srem('tid:' + tid + ':followers', current_user, function(err, success) {
|
RDB.srem('tid:' + tid + ':followers', current_user, function(err, success) {
|
||||||
if (!err) {
|
if (callback) {
|
||||||
callback({
|
if (!err) {
|
||||||
status: 'ok',
|
callback({
|
||||||
follow: false
|
status: 'ok',
|
||||||
});
|
follow: false
|
||||||
} else callback({ status: 'error' });
|
});
|
||||||
|
} else callback({ status: 'error' });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -353,6 +353,9 @@ marked.setOptions({
|
|||||||
if (pid > 0) {
|
if (pid > 0) {
|
||||||
RDB.lpush(schema.topics(tid).posts, pid);
|
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
|
// Notify any users looking at the category that a new topic has arrived
|
||||||
Topics.get_topic(tid, uid, function(topicData) {
|
Topics.get_topic(tid, uid, function(topicData) {
|
||||||
io.sockets.in('category_' + category_id).emit('event:new_topic', topicData);
|
io.sockets.in('category_' + category_id).emit('event:new_topic', topicData);
|
||||||
|
|||||||
Reference in New Issue
Block a user