mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-02 22:00:34 +01:00
closes #1941
This commit is contained in:
@@ -22,49 +22,50 @@ module.exports = function(Topics) {
|
||||
};
|
||||
|
||||
Topics.notifyFollowers = function(tid, pid, exceptUid) {
|
||||
async.parallel({
|
||||
nid: function(next) {
|
||||
async.parallel({
|
||||
topicData: async.apply(Topics.getTopicFields, tid, ['title', 'slug']),
|
||||
username: async.apply(user.getUserField, exceptUid, 'username'),
|
||||
postIndex: async.apply(posts.getPidIndex, pid),
|
||||
postContent: function(next) {
|
||||
async.waterfall([
|
||||
async.apply(posts.getPostField, pid, 'content'),
|
||||
function(content, next) {
|
||||
postTools.parse(content, next);
|
||||
}
|
||||
], next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
notifications.create({
|
||||
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topicData.title + ']]',
|
||||
bodyLong: results.postContent,
|
||||
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.postIndex,
|
||||
uniqueId: 'topic:' + tid + ':uid:' + exceptUid,
|
||||
tid: tid,
|
||||
from: exceptUid
|
||||
}, next);
|
||||
});
|
||||
},
|
||||
followers: function(next) {
|
||||
Topics.getFollowers(tid, next);
|
||||
Topics.getFollowers(tid, function(err, followers) {
|
||||
if (err || !Array.isArray(followers) || !followers.length) {
|
||||
return;
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (!err && results.followers.length) {
|
||||
|
||||
var index = results.followers.indexOf(exceptUid.toString());
|
||||
if (index !== -1) {
|
||||
results.followers.splice(index, 1);
|
||||
var index = followers.indexOf(exceptUid.toString());
|
||||
if (index !== -1) {
|
||||
followers.splice(index, 1);
|
||||
}
|
||||
|
||||
if (!followers.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
topicData: async.apply(Topics.getTopicFields, tid, ['title', 'slug']),
|
||||
username: async.apply(user.getUserField, exceptUid, 'username'),
|
||||
postIndex: async.apply(posts.getPidIndex, pid),
|
||||
postContent: function(next) {
|
||||
async.waterfall([
|
||||
async.apply(posts.getPostField, pid, 'content'),
|
||||
function(content, next) {
|
||||
postTools.parse(content, next);
|
||||
}
|
||||
], next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
notifications.push(results.nid, results.followers);
|
||||
}
|
||||
notifications.create({
|
||||
bodyShort: '[[notifications:user_posted_to, ' + results.username + ', ' + results.topicData.title + ']]',
|
||||
bodyLong: results.postContent,
|
||||
path: nconf.get('relative_path') + '/topic/' + results.topicData.slug + '/' + results.postIndex,
|
||||
uniqueId: 'topic:' + tid + ':uid:' + exceptUid,
|
||||
tid: tid,
|
||||
from: exceptUid
|
||||
}, function(err, nid) {
|
||||
if (!err) {
|
||||
notifications.push(nid, followers);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user