mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-24 08:19:48 +01:00
closes #3912
This commit is contained in:
@@ -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 bodyShort
|
||||
if (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;
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user