mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 11:01:20 +01:00
refactor: use translator.compile which escapes % and ,
This commit is contained in:
@@ -18,6 +18,7 @@ const privileges = require('./privileges');
|
|||||||
const plugins = require('./plugins');
|
const plugins = require('./plugins');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const batch = require('./batch');
|
const batch = require('./batch');
|
||||||
|
const translator = require('./translator');
|
||||||
|
|
||||||
const Flags = module.exports;
|
const Flags = module.exports;
|
||||||
|
|
||||||
@@ -747,7 +748,6 @@ Flags.update = async function (flagId, uid, changeset) {
|
|||||||
const notifObj = await notifications.create({
|
const notifObj = await notifications.create({
|
||||||
type: 'my-flags',
|
type: 'my-flags',
|
||||||
bodyShort: `[[notifications:flag-assigned-to-you, ${flagId}]]`,
|
bodyShort: `[[notifications:flag-assigned-to-you, ${flagId}]]`,
|
||||||
bodyLong: '',
|
|
||||||
path: `/flags/${flagId}`,
|
path: `/flags/${flagId}`,
|
||||||
nid: `flags:assign:${flagId}:uid:${assigneeId}`,
|
nid: `flags:assign:${flagId}:uid:${assigneeId}`,
|
||||||
from: uid,
|
from: uid,
|
||||||
@@ -929,11 +929,11 @@ Flags.notify = async function (flagObj, uid, notifySelf = false) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const modUids = await categories.getModeratorUids([cid]);
|
const modUids = await categories.getModeratorUids([cid]);
|
||||||
const titleEscaped = utils.decodeHTMLEntities(title).replace(/%/g, '%').replace(/,/g, ',');
|
const titleEscaped = utils.decodeHTMLEntities(title);
|
||||||
|
|
||||||
notifObj = await notifications.create({
|
notifObj = await notifications.create({
|
||||||
type: 'new-post-flag',
|
type: 'new-post-flag',
|
||||||
bodyShort: `[[notifications:user-flagged-post-in, ${displayname}, ${titleEscaped}]]`,
|
bodyShort: translator.compile('notifications:user-flagged-post-in', displayname, titleEscaped),
|
||||||
bodyLong: String(flagObj.target?.content || ''),
|
bodyLong: String(flagObj.target?.content || ''),
|
||||||
pid: flagObj.targetId,
|
pid: flagObj.targetId,
|
||||||
path: `/flags/${flagObj.flagId}`,
|
path: `/flags/${flagObj.flagId}`,
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ module.exports = function (Groups) {
|
|||||||
const notificationData = await Promise.all(uids.map(uid => notifications.create({
|
const notificationData = await Promise.all(uids.map(uid => notifications.create({
|
||||||
type: 'group-invite',
|
type: 'group-invite',
|
||||||
bodyShort: `[[groups:invited.notification-title, ${groupName}]]`,
|
bodyShort: `[[groups:invited.notification-title, ${groupName}]]`,
|
||||||
bodyLong: '',
|
|
||||||
nid: `group:${groupName}:uid:${uid}:invite`,
|
nid: `group:${groupName}:uid:${uid}:invite`,
|
||||||
path: `/groups/${slugify(groupName)}`,
|
path: `/groups/${slugify(groupName)}`,
|
||||||
icon: 'fa-users',
|
icon: 'fa-users',
|
||||||
|
|||||||
@@ -113,8 +113,7 @@ SocketHelpers.sendNotificationToPostOwner = async function (pid, fromuid, comman
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const title = utils.decodeHTMLEntities(topicTitle);
|
const title = utils.decodeHTMLEntities(topicTitle);
|
||||||
const titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
const bodyShort = translator.compile(notification, userData.displayname || userData.name, title);
|
||||||
const bodyShort = translator.compile(notification, userData.displayname || userData.name, titleEscaped);
|
|
||||||
|
|
||||||
const notifObj = await notifications.create({
|
const notifObj = await notifications.create({
|
||||||
type: command,
|
type: command,
|
||||||
@@ -153,10 +152,9 @@ SocketHelpers.sendNotificationToTopicOwner = async function (tid, fromuid, comma
|
|||||||
|
|
||||||
const ownerUid = topicData.uid;
|
const ownerUid = topicData.uid;
|
||||||
const title = utils.decodeHTMLEntities(topicData.title);
|
const title = utils.decodeHTMLEntities(topicData.title);
|
||||||
const titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
|
||||||
|
|
||||||
const notifObj = await notifications.create({
|
const notifObj = await notifications.create({
|
||||||
bodyShort: `[[${notification}, ${displayname}, ${titleEscaped}]]`,
|
bodyShort: translator.compile(notification, displayname, title),
|
||||||
path: `/topic/${topicData.slug}`,
|
path: `/topic/${topicData.slug}`,
|
||||||
nid: `${command}:tid:${tid}:uid:${fromuid}`,
|
nid: `${command}:tid:${tid}:uid:${fromuid}`,
|
||||||
from: fromuid,
|
from: fromuid,
|
||||||
|
|||||||
Reference in New Issue
Block a user