diff --git a/src/threadTools.js b/src/threadTools.js index 201cf7afe8..31ba63b631 100644 --- a/src/threadTools.js +++ b/src/threadTools.js @@ -263,23 +263,36 @@ var winston = require('winston'), }); } - ThreadTools.notifyFollowers = function(tid, exceptUid) { + ThreadTools.notifyFollowers = function(tid, pid, exceptUid) { async.parallel([ function(next) { - topics.getTopicField(tid, 'title', function(err, title) { - topics.getTeaser(tid, function(err, teaser) { - if (!err) { - notifications.create('' + teaser.username + ' has posted a reply to: "' + title + '"', nconf.get('relative_path') + '/topic/' + tid, 'topic:' + tid, function(nid) { - next(null, nid); - }); - } else next(err); + topics.getTopicFields(tid, ['title', 'slug'], function(err, topicData) { + if(err) { + return next(err); + } + + user.getUserField(exceptUid, 'username', function(err, username) { + if(err) { + return next(err); + } + + notifications.create('' + username + ' has posted a reply to: "' + topicData.title + '"', nconf.get('relative_path') + '/topic/' + topicData.slug + '#' + pid, 'topic:' + tid, function(nid) { + next(null, nid); + }); }); }); }, function(next) { ThreadTools.getFollowers(tid, function(err, followers) { + if(err) { + return next(err); + } + exceptUid = parseInt(exceptUid, 10); - if (followers.indexOf(exceptUid) !== -1) followers.splice(followers.indexOf(exceptUid), 1); + if (followers.indexOf(exceptUid) !== -1) { + followers.splice(followers.indexOf(exceptUid), 1); + } + next(null, followers); }); } diff --git a/src/topics.js b/src/topics.js index b832817f88..b56b742f0b 100644 --- a/src/topics.js +++ b/src/topics.js @@ -164,7 +164,7 @@ var async = require('async'), }); feed.updateRecent(); - threadTools.notifyFollowers(tid, uid); + threadTools.notifyFollowers(tid, postData.pid, uid); user.sendPostNotificationToFollowers(uid, tid, postData.pid); Topics.markCategoryUnreadForAll(tid, function(err) {