mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 10:46:14 +01:00
refactor: remove chat message notification queue, implement merge IDs for chat message notifications, so they can be grouped together
This commit is contained in:
@@ -374,6 +374,7 @@ Notifications.merge = async function (notifications) {
|
||||
'notifications:user_posted_to',
|
||||
'notifications:user_flagged_post_in',
|
||||
'notifications:user_flagged_user',
|
||||
'new-chat',
|
||||
'notifications:user_posted_in_public_room',
|
||||
'new_register',
|
||||
'post-queue',
|
||||
@@ -417,6 +418,15 @@ Notifications.merge = async function (notifications) {
|
||||
}
|
||||
const notifObj = notifications[modifyIndex];
|
||||
switch (mergeId) {
|
||||
case 'new-chat': {
|
||||
const { roomId, roomName, type, user } = set[0];
|
||||
const isGroupChat = type === 'new-group-chat';
|
||||
notifObj.bodyShort = isGroupChat || (roomName !== `[[modules:chat.room-id, ${roomId}]]`) ?
|
||||
`[[notifications:new_messages_in, ${set.length}, ${roomName}]]` :
|
||||
`[[notifications:new_messages_from, ${set.length}, ${user.displayname}]]`;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'notifications:user_posted_in_public_room': {
|
||||
const usernames = _.uniq(set.map(notifObj => notifObj && notifObj.user && notifObj.user.displayname));
|
||||
if (usernames.length === 2 || usernames.length === 3) {
|
||||
|
||||
Reference in New Issue
Block a user