From 92db112367514c0114e481c79d9620b6b6bafcb1 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 16 Apr 2014 15:51:05 -0400 Subject: [PATCH] reverted previous commit --- public/language/en_GB/notifications.json | 1 + src/topics/create.js | 3 ++- src/user/notifications.js | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/public/language/en_GB/notifications.json b/public/language/en_GB/notifications.json index 489e0c6077..d480d39a2e 100644 --- a/public/language/en_GB/notifications.json +++ b/public/language/en_GB/notifications.json @@ -11,6 +11,7 @@ "new_notification": "New Notification", "you_have_unread_notifications": "You have unread notifications.", + "user_made_post": "%1 made a new post", "new_message_from": "New message from %1", "upvoted_your_post": "%1 has upvoted your post.", "favourited_your_post": "%1 has favourited your post.", diff --git a/src/topics/create.js b/src/topics/create.js index 8b59929726..f597b53d7d 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -180,9 +180,10 @@ module.exports = function(Topics) { }, function(data, next) { postData = data; - threadTools.notifyFollowers(tid, postData.pid, uid); + user.notifications.sendPostNotificationToFollowers(uid, tid, postData.pid); + next(); }, function(next) { diff --git a/src/user/notifications.js b/src/user/notifications.js index d949222429..fd6c0dab72 100644 --- a/src/user/notifications.js +++ b/src/user/notifications.js @@ -148,6 +148,27 @@ var async = require('async'), }); }; + UserNotifications.sendPostNotificationToFollowers = function(uid, tid, pid) { + user.getUserField(uid, 'username', function(err, username) { + db.getSetMembers('followers:' + uid, function(err, followers) { + if (followers && followers.length) { + topics.getTopicField(tid, 'slug', function(err, slug) { + var message = '[[notifications:user_made_post, ' + username + ']]'; + + notifications.create({ + text: message, + path: nconf.get('relative_path') + '/topic/' + slug + '#' + pid, + uniqueId: 'topic:' + tid, + from: uid + }, function(nid) { + notifications.push(nid, followers); + }); + }); + } + }); + }); + }; + UserNotifications.pushCount = function(uid) { var websockets = require('./../socket.io'); UserNotifications.getUnreadCount(uid, function(err, count) {