Node.js based forum software built for the modern web
closes #3912
Julian Lam05df8900db4f
diff --git a/public/language/en_GB/notifications.json b/public/language/en_GB/notifications.jsonindex 3048f082b9..0692155373 100644--- a/public/language/en_GB/notifications.json+++ b/public/language/en_GB/notifications.json@@ -14,15 +14,23 @@"new_message_from": "New message from <strong>%1</strong>","upvoted_your_post_in": "<strong>%1</strong> has upvoted your post in <strong>%2</strong>.",+ "upvoted_your_post_in_dual": "<strong>%1</strong> and <strong>%2</strong> have upvoted your post in <strong>%3</strong>.",+ "upvoted_your_post_in_multiple": "<strong>%1</strong> and %2 others have upvoted your post in <strong>%3</strong>.","moved_your_post": "<strong>%1</strong> has moved your post to <strong>%2</strong>","moved_your_topic": "<strong>%1</strong> has moved <strong>%2</strong>","favourited_your_post_in": "<strong>%1</strong> has favourited your post in <strong>%2</strong>.","favourited_your_post_in_dual": "<strong>%1</strong> and <strong>%2</strong> have favourited your post in <strong>%3</strong>.","favourited_your_post_in_multiple": "<strong>%1</strong> and %2 others have favourited your post in <strong>%3</strong>.","user_flagged_post_in": "<strong>%1</strong> flagged a post in <strong>%2</strong>",+ "user_flagged_post_in_dual": "<strong>%1</strong> and <strong>%2</strong> flagged a post in <strong>%3</strong>",+ "user_flagged_post_in_multiple": "<strong>%1</strong> and %2 others flagged a post in <strong>%3</strong>","user_posted_to" : "<strong>%1</strong> has posted a reply to: <strong>%2</strong>",+ "user_posted_to_dual" : "<strong>%1</strong> and <strong>%2</strong> have posted replies to: <strong>%3</strong>",+ "user_posted_to_multiple" : "<strong>%1</strong> and %2 others have posted replies to: <strong>%3</strong>","user_posted_topic": "<strong>%1</strong> has posted a new topic: <strong>%2</strong>","user_started_following_you": "<strong>%1</strong> started following you.",+ "user_started_following_you_dual": "<strong>%1</strong> and <strong>%2</strong> started following you.",+ "user_started_following_you_multiple": "<strong>%1</strong> and %2 others started following you.","new_register": "<strong>%1</strong> sent a registration request.","email-confirmed": "Email Confirmed",diff --git a/src/notifications.js b/src/notifications.jsindex ec77cb4a99..c09f438fc9 100644--- a/src/notifications.js+++ b/src/notifications.js@@ -333,12 +333,18 @@ var async = require('async'),Notifications.merge = function(notifications, callback) {// When passed a set of notification objects, merge any that can be merged- var mergeIds = ['notifications:favourited_your_post_in'],+ var mergeIds = [+ 'notifications:favourited_your_post_in',+ 'notifications:upvoted_your_post_in',+ 'notifications:user_started_following_you',+ 'notifications:user_posted_to',+ 'notifications:user_flagged_post_in'+ ],isolated, modifyIndex;notifications = mergeIds.reduce(function(notifications, mergeId) {isolated = notifications.filter(function(notifObj) {- return notifObj.mergeId === mergeId;+ return notifObj.mergeId.split('|')[0] === mergeId;});if (isolated.length <= 1) {@@ -348,7 +354,11 @@ var async = require('async'),modifyIndex = notifications.indexOf(isolated[0]);switch(mergeId) {- case 'notifications:favourited_your_post_in':+ case 'notifications:favourited_your_post_in': // intentional fall-through+ case 'notifications:upvoted_your_post_in':+ case 'notifications:user_started_following_you':+ case 'notifications:user_posted_to':+ case 'notifications:user_flagged_post_in':var usernames = isolated.map(function(notifObj) {return notifObj.user.username;});@@ -356,9 +366,9 @@ var async = require('async'),// Update bodyShortif (numUsers === 2) {- isolated[0].bodyShort = '[[notifications:favourited_your_post_in_dual, ' + usernames.join(', ') + ', Welcome to your NodeBB!]]'+ isolated[0].bodyShort = '[[' + mergeId.split('|') + '_dual, ' + usernames.join(', ') + ', ' + isolated[0].topicTitle + ']]'} else {- isolated[0].bodyShort = '[[notifications:favourited_your_post_in_multiple, ' + usernames[0] + ', ' + (numUsers-1) + ', Welcome to your NodeBB!]]'+ isolated[0].bodyShort = '[[' + mergeId.split('|') + '_multiple, ' + usernames[0] + ', ' + (numUsers-1) + ', ' + isolated[0].topicTitle + ']]'}break;}diff --git a/src/socket.io/helpers.js b/src/socket.io/helpers.jsindex 19e46871b3..789ec1660a 100644--- a/src/socket.io/helpers.js+++ b/src/socket.io/helpers.js@@ -70,7 +70,8 @@ SocketHelpers.sendNotificationToPostOwner = function(pid, fromuid, notification)pid: pid,nid: 'post:' + pid + ':uid:' + fromuid,from: fromuid,- mergeId: notification+ mergeId: notification + '|' + postData.tid,+ topicTitle: results.topicTitle}, function(err, notification) {if (!err && notification) {notifications.push(notification, [postData.uid]);diff --git a/src/socket.io/posts/flag.js b/src/socket.io/posts/flag.jsindex aa82e84626..d3f4007e01 100644--- a/src/socket.io/posts/flag.js+++ b/src/socket.io/posts/flag.js@@ -84,7 +84,9 @@ module.exports = function(SocketPosts) {bodyLong: post.content,pid: data.pid,nid: 'post_flag:' + data.pid + ':uid:' + socket.uid,- from: socket.uid+ from: socket.uid,+ mergeId: 'notifications:user_flagged_post_in|' + data.pid,+ topicTitle: post.topic.title}, function(err, notification) {if (err || !notification) {return next(err);diff --git a/src/socket.io/user.js b/src/socket.io/user.jsindex 14b0c2c828..3a19d62d63 100644--- a/src/socket.io/user.js+++ b/src/socket.io/user.js@@ -142,7 +142,8 @@ SocketUser.follow = function(socket, data, callback) {bodyShort: '[[notifications:user_started_following_you, ' + userData.username + ']]',nid: 'follow:' + data.uid + ':uid:' + socket.uid,from: socket.uid,- path: '/user/' + userData.userslug+ path: '/user/' + userData.userslug,+ mergeId: 'notifications:user_started_following_you'}, next);},function(notification, next) {diff --git a/src/topics/follow.js b/src/topics/follow.jsindex e05a705c51..250f571dc4 100644--- a/src/topics/follow.js+++ b/src/topics/follow.js@@ -137,7 +137,9 @@ module.exports = function(Topics) {pid: postData.pid,nid: 'new_post:tid:' + postData.topic.tid + ':pid:' + postData.pid + ':uid:' + exceptUid,tid: postData.topic.tid,- from: exceptUid+ from: exceptUid,+ mergeId: 'notifications:user_posted_to|' + postData.topic.tid,+ topicTitle: title}, function(err, notification) {if (err) {return next(err);