Skip to content

Commit

Permalink
feat: translate bodyShort
Browse files Browse the repository at this point in the history
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
  • Loading branch information
barisusakli committed May 21, 2023
1 parent cdeaef6 commit ed15cbb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/user/notifications.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [];
Expand All @@ -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,
Expand Down

0 comments on commit ed15cbb

Please sign in to comment.