Node.js based forum software built for the modern web
reverted previous commit
barisusakli92db11236751
diff --git a/public/language/en_GB/notifications.json b/public/language/en_GB/notifications.jsonindex 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": "<strong>%1</strong> made a new post","new_message_from": "New message from <strong>%1</strong>","upvoted_your_post": "<strong>%1</strong> has upvoted your post.","favourited_your_post": "<strong>%1</strong> has favourited your post.",diff --git a/src/topics/create.js b/src/topics/create.jsindex 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.jsindex 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) {