From ed15cbb06a53114b16e9a722bf28e0ce550f136e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 21 May 2023 15:54:18 -0400 Subject: [PATCH] feat: translate bodyShort turns [[notifications:upvoted_your_post_in, test1, Vote *for* NodeBB :ballot_box_with_ballot:]] into test1 has upvoted your post in Vote *for* NodeBB :ballot_box_with_ballot:. so emoji plugin can parse emojis and they don't get escaped by translator client side --- src/user/notifications.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/user/notifications.js b/src/user/notifications.js index d0efa369a142..04a0fb5ea604 100644 --- a/src/user/notifications.js +++ b/src/user/notifications.js @@ -9,6 +9,8 @@ const meta = require('../meta'); const notifications = require('../notifications'); const privileges = require('../privileges'); const plugins = require('../plugins'); +const translator = require('../translator'); +const user = require('./index'); const utils = require('../utils'); const UserNotifications = module.exports; @@ -99,9 +101,10 @@ UserNotifications.getNotifications = async function (nids, uid) { return []; } - const [notifObjs, hasRead] = await Promise.all([ + const [notifObjs, hasRead, userSettings] = await Promise.all([ notifications.getMultiple(nids), db.isSortedSetMembers(`uid:${uid}:notifications:read`, nids), + user.getSettings(uid), ]); const deletedNids = []; @@ -119,6 +122,12 @@ UserNotifications.getNotifications = async function (nids, uid) { await deleteUserNids(deletedNids, uid); notificationData = await notifications.merge(notificationData); + await Promise.all(notificationData.map(async (n) => { + if (n && n.bodyShort) { + n.bodyShort = await translator.translate(n.bodyShort, userSettings.userLang); + } + })); + const result = await plugins.hooks.fire('filter:user.notifications.getNotifications', { uid: uid, notifications: notificationData,