From 34b681094544e694457ab81dc9ede3c417301f53 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:09:59 -0400 Subject: [PATCH] fix: merged notification translations not escaping commas properly, use translator.compile --- src/notifications.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/notifications.js b/src/notifications.js index e52be01609..83e3e163b3 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -18,6 +18,7 @@ const plugins = require('./plugins'); const utils = require('./utils'); const emailer = require('./emailer'); const ttlCache = require('./cache/ttl'); +const translator = require('./translator'); const Notifications = module.exports; @@ -563,21 +564,18 @@ Notifications.merge = async function (notifications) { const usernames = _.uniq(set.map(notifObj => notifObj && notifObj.user && notifObj.user.displayname)); const numUsers = usernames.length; - const title = utils.decodeHTMLEntities(notifications[modifyIndex].topicTitle || ''); - let titleEscaped = title.replace(/%/g, '%').replace(/,/g, ','); - titleEscaped = titleEscaped ? (`, ${titleEscaped}`) : ''; + const title = utils.decodeHTMLEntities(notifObj.topicTitle || ''); - if (numUsers === 2 || numUsers === 3) { - notifications[modifyIndex].bodyShort = `[[${mergeId}-${typeFromLength(usernames)}, ${usernames.join(', ')}${titleEscaped}]]`; - } else if (numUsers > 2) { - notifications[modifyIndex].bodyShort = `[[${mergeId}-${typeFromLength(usernames)}, ${usernames.slice(0, 2).join(', ')}, ${numUsers - 2}${titleEscaped}]]`; - } + const txKey = `${mergeId}-${typeFromLength(usernames)}`; + const displayNames = usernames.slice(0, numUsers <= 3 ? 3 : 2).join(', '); + notifObj.bodyShort = translator.compile(txKey, displayNames, title || ''); - notifications[modifyIndex].path = set[set.length - 1].path; - } break; + notifObj.path = set[set.length - 1].path; + break; + } case 'new-register': - notifications[modifyIndex].bodyShort = `[[notifications:${mergeId}-multiple, ${set.length}]]`; + notifObj.bodyShort = `[[notifications:${mergeId}-multiple, ${set.length}]]`; break; }