From 9d0f53fcd64a9c37af86c0693b83d8b0c6c5540b Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 1 Mar 2016 16:42:19 -0500 Subject: [PATCH] closed #4098 --- public/language/en_GB/notifications.json | 1 + src/notifications.js | 20 +++++++++++++++----- src/user/approval.js | 3 ++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/public/language/en_GB/notifications.json b/public/language/en_GB/notifications.json index a02cada4a6..07ec757374 100644 --- a/public/language/en_GB/notifications.json +++ b/public/language/en_GB/notifications.json @@ -32,6 +32,7 @@ "user_started_following_you_dual": "%1 and %2 started following you.", "user_started_following_you_multiple": "%1 and %2 others started following you.", "new_register": "%1 sent a registration request.", + "new_register_multiple": "There are %1 registration requests awaiting review.", "email-confirmed": "Email Confirmed", "email-confirmed-message": "Thank you for validating your email. Your account is now fully activated.", diff --git a/src/notifications.js b/src/notifications.js index 2351319413..1776103031 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -395,7 +395,8 @@ var async = require('async'), 'notifications:upvoted_your_post_in', 'notifications:user_started_following_you', 'notifications:user_posted_to', - 'notifications:user_flagged_post_in' + 'notifications:user_flagged_post_in', + 'new_register' ], isolated, differentiators, differentiator, modifyIndex, set; @@ -414,7 +415,7 @@ var async = require('async'), // Each isolated mergeId may have multiple differentiators, so process each separately differentiators = isolated.reduce(function(cur, next) { - differentiator = next.mergeId.split('|')[1]; + differentiator = next.mergeId.split('|')[1] || 0; if (cur.indexOf(differentiator) === -1) { cur.push(differentiator); } @@ -423,9 +424,14 @@ var async = require('async'), }, []); differentiators.forEach(function(differentiator) { - set = isolated.filter(function(notifObj) { - return notifObj.mergeId === (mergeId + '|' + differentiator); - }); + if (differentiator === 0 && differentiators.length === 1) { + set = isolated; + } else { + set = isolated.filter(function(notifObj) { + return notifObj.mergeId === (mergeId + '|' + differentiator); + }); + } + modifyIndex = notifications.indexOf(set[0]); if (modifyIndex === -1 || set.length === 1) { return notifications; @@ -450,6 +456,10 @@ var async = require('async'), notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers-1) + ', ' + notifications[modifyIndex].topicTitle + ']]'; } break; + + case 'new_register': + notifications[modifyIndex].bodyShort = '[[notifications:' + mergeId + '_multiple, ' + set.length + ']]'; + break; } // Filter out duplicates diff --git a/src/user/approval.js b/src/user/approval.js index a4a3981002..9ed17be898 100644 --- a/src/user/approval.js +++ b/src/user/approval.js @@ -47,7 +47,8 @@ module.exports = function(User) { notifications.create({ bodyShort: '[[notifications:new_register, ' + username + ']]', nid: 'new_register:' + username, - path: '/admin/manage/registration' + path: '/admin/manage/registration', + mergeId: 'new_register' }, function(err, notification) { if (err || !notification) { return callback(err);