mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: translate bodyShort
turns [[notifications:upvoted_your_post_in, test1, Vote *for* NodeBB :ballot_box_with_ballot:]] into <strong>test1</strong> has upvoted your post in <strong>Vote *for* NodeBB :ballot_box_with_ballot:</strong>. so emoji plugin can parse emojis and they don't get escaped by translator client side
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user