From 4ee4ba9a011bd1134f85c4caf97834763769a223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 11 Mar 2026 12:18:27 -0400 Subject: [PATCH 1/2] cleaner --- src/notifications.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/notifications.js b/src/notifications.js index 83e3e163b3..903380960a 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -562,14 +562,10 @@ Notifications.merge = async function (notifications) { case 'notifications:user-flagged-user': case 'notifications:activitypub.announce': { const usernames = _.uniq(set.map(notifObj => notifObj && notifObj.user && notifObj.user.displayname)); - const numUsers = usernames.length; - - const title = utils.decodeHTMLEntities(notifObj.topicTitle || ''); - const txKey = `${mergeId}-${typeFromLength(usernames)}`; - const displayNames = usernames.slice(0, numUsers <= 3 ? 3 : 2).join(', '); + const displayNames = usernames.slice(0, usernames.length <= 3 ? 3 : 2).join(', '); + const title = utils.decodeHTMLEntities(notifObj.topicTitle || ''); notifObj.bodyShort = translator.compile(txKey, displayNames, title || ''); - notifObj.path = set[set.length - 1].path; break; } From e1d0e2a0db4bce2906f1ee1637ff36e9f46f9ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 11 Mar 2026 12:31:26 -0400 Subject: [PATCH 2/2] fix: merge with txArgs --- src/notifications.js | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/notifications.js b/src/notifications.js index 903380960a..63d5ab6d7f 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -545,13 +545,18 @@ Notifications.merge = async function (notifications) { } 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) { - notifObj.bodyShort = `[[${mergeId}-${typeFromLength(usernames)}, ${usernames.join(', ')}, ${notifObj.roomIcon}, ${notifObj.roomName}]]`; - } else if (usernames.length > 3) { - notifObj.bodyShort = `[[${mergeId}-${typeFromLength(usernames)}, ${usernames.slice(0, 2).join(', ')}, ${usernames.length - 2}, ${notifObj.roomIcon}, ${notifObj.roomName}]]`; - } + const usernames = _.uniq(set.map(n => n?.user?.displayname)).filter(Boolean); + const type = typeFromLength(usernames); + const isMultiple = type === 'multiple'; + const txArgs = [ + `${mergeId}-${type}`, + usernames.slice(0, usernames.length <= 3 ? 3 : 2).join(', '), + ...(isMultiple ? [usernames.length - 2] : []), + notifObj.roomIcon, + notifObj.roomName, + ]; + notifObj.bodyShort = translator.compile(...txArgs); notifObj.path = set[set.length - 1].path; break; } @@ -561,11 +566,16 @@ Notifications.merge = async function (notifications) { case 'notifications:user-flagged-post-in': case 'notifications:user-flagged-user': case 'notifications:activitypub.announce': { - const usernames = _.uniq(set.map(notifObj => notifObj && notifObj.user && notifObj.user.displayname)); - const txKey = `${mergeId}-${typeFromLength(usernames)}`; - const displayNames = usernames.slice(0, usernames.length <= 3 ? 3 : 2).join(', '); - const title = utils.decodeHTMLEntities(notifObj.topicTitle || ''); - notifObj.bodyShort = translator.compile(txKey, displayNames, title || ''); + const usernames = _.uniq(set.map(n => n?.user?.displayname)).filter(Boolean); + const type = typeFromLength(usernames); + const isMultiple = type === 'multiple'; + const txArgs = [ + `${mergeId}-${type}`, + usernames.slice(0, usernames.length <= 3 ? 3 : 2).join(', '), + ...(isMultiple ? [usernames.length - 2] : []), + utils.decodeHTMLEntities(notifObj.topicTitle || ''), + ]; + notifObj.bodyShort = translator.compile(...txArgs); notifObj.path = set[set.length - 1].path; break; }