From f0428f5f1f25a84ed74596a2388ac811d548e82b Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 16 Apr 2014 15:46:50 -0400 Subject: [PATCH] removed double post notification #1386 --- public/language/en_GB/notifications.json | 1 - src/socket.io/posts.js | 9 +++------ src/topics/create.js | 3 +-- src/user/notifications.js | 21 --------------------- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/public/language/en_GB/notifications.json b/public/language/en_GB/notifications.json index d480d39a2e..489e0c6077 100644 --- a/public/language/en_GB/notifications.json +++ b/public/language/en_GB/notifications.json @@ -11,7 +11,6 @@ "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/socket.io/posts.js b/src/socket.io/posts.js index 05507f4660..dde786af7e 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -33,14 +33,11 @@ SocketPosts.reply = function(socket, data, callback) { } if (postData) { - - module.parent.exports.emitTopicPostStats(); - - var socketData = { + websockets.server.sockets.emit('event:new_post', { posts: [postData] - }; + }); - websockets.server.sockets.emit('event:new_post', socketData); + module.parent.exports.emitTopicPostStats(); callback(); } diff --git a/src/topics/create.js b/src/topics/create.js index f597b53d7d..8b59929726 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -180,9 +180,8 @@ module.exports = function(Topics) { }, function(data, next) { postData = data; - threadTools.notifyFollowers(tid, postData.pid, uid); - user.notifications.sendPostNotificationToFollowers(uid, tid, postData.pid); + threadTools.notifyFollowers(tid, postData.pid, uid); next(); }, diff --git a/src/user/notifications.js b/src/user/notifications.js index fd6c0dab72..d949222429 100644 --- a/src/user/notifications.js +++ b/src/user/notifications.js @@ -148,27 +148,6 @@ 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) {