mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
fix: possible fix to escaped emoji in titles
This commit is contained in:
@@ -594,9 +594,10 @@ module.exports = function (Topics) {
|
|||||||
}
|
}
|
||||||
tags = tags.map(tag => tag.value);
|
tags = tags.map(tag => tag.value);
|
||||||
|
|
||||||
const [followersOfPoster, allFollowers] = await Promise.all([
|
const [followersOfPoster, allFollowers, title] = await Promise.all([
|
||||||
db.getSortedSetRange(`followers:${exceptUid}`, 0, -1),
|
db.getSortedSetRange(`followers:${exceptUid}`, 0, -1),
|
||||||
db.getSortedSetRange(tags.map(tag => `tag:${tag}:followers`), 0, -1),
|
db.getSortedSetRange(tags.map(tag => `tag:${tag}:followers`), 0, -1),
|
||||||
|
Topics.getTopicField(postData.topic.tid, 'title'),
|
||||||
]);
|
]);
|
||||||
const followerSet = new Set(followersOfPoster);
|
const followerSet = new Set(followersOfPoster);
|
||||||
// filter out followers of the poster since they get a notification already
|
// filter out followers of the poster since they get a notification already
|
||||||
@@ -609,13 +610,13 @@ module.exports = function (Topics) {
|
|||||||
const { displayname } = postData.user;
|
const { displayname } = postData.user;
|
||||||
|
|
||||||
const notifBase = 'notifications:user-posted-topic-with-tag';
|
const notifBase = 'notifications:user-posted-topic-with-tag';
|
||||||
let bodyShort = translator.compile(notifBase, displayname, postData.topic.title, tags[0]);
|
let bodyShort = translator.compile(notifBase, displayname, title, tags[0]);
|
||||||
if (tags.length === 2) {
|
if (tags.length === 2) {
|
||||||
bodyShort = translator.compile(`${notifBase}-dual`, displayname, postData.topic.title, tags[0], tags[1]);
|
bodyShort = translator.compile(`${notifBase}-dual`, displayname, title, tags[0], tags[1]);
|
||||||
} else if (tags.length === 3) {
|
} else if (tags.length === 3) {
|
||||||
bodyShort = translator.compile(`${notifBase}-triple`, displayname, postData.topic.title, tags[0], tags[1], tags[2]);
|
bodyShort = translator.compile(`${notifBase}-triple`, displayname, title, tags[0], tags[1], tags[2]);
|
||||||
} else if (tags.length > 3) {
|
} else if (tags.length > 3) {
|
||||||
bodyShort = translator.compile(`${notifBase}-multiple`, displayname, postData.topic.title, tags.join(', '));
|
bodyShort = translator.compile(`${notifBase}-multiple`, displayname, title, tags.join(', '));
|
||||||
}
|
}
|
||||||
|
|
||||||
const notification = await notifications.create({
|
const notification = await notifications.create({
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const notifications = require('../notifications');
|
|||||||
const privileges = require('../privileges');
|
const privileges = require('../privileges');
|
||||||
const plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
const translator = require('../translator');
|
const translator = require('../translator');
|
||||||
|
const topics = require('../topics');
|
||||||
const user = require('./index');
|
const user = require('./index');
|
||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
|
|
||||||
@@ -201,15 +202,18 @@ UserNotifications.deleteAll = async function (uid) {
|
|||||||
|
|
||||||
UserNotifications.sendTopicNotificationToFollowers = async function (uid, topicData, postData) {
|
UserNotifications.sendTopicNotificationToFollowers = async function (uid, topicData, postData) {
|
||||||
try {
|
try {
|
||||||
let followers = await db.getSortedSetRange(`followers:${uid}`, 0, -1);
|
const [allFollowers, title] = await Promise.all([
|
||||||
followers = await privileges.categories.filterUids('read', topicData.cid, followers);
|
db.getSortedSetRange(`followers:${uid}`, 0, -1),
|
||||||
|
topics.getTopicField(topicData.tid, 'title'),
|
||||||
|
]);
|
||||||
|
const followers = await privileges.categories.filterUids('read', topicData.cid, allFollowers);
|
||||||
if (!followers.length) {
|
if (!followers.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const notifObj = await notifications.create({
|
const notifObj = await notifications.create({
|
||||||
type: 'new-topic',
|
type: 'new-topic',
|
||||||
bodyShort: translator.compile('notifications:user-posted-topic', postData.user.displayname, postData.topic.title),
|
bodyShort: translator.compile('notifications:user-posted-topic', postData.user.displayname, title),
|
||||||
bodyLong: postData.content,
|
bodyLong: postData.content,
|
||||||
pid: postData.pid,
|
pid: postData.pid,
|
||||||
path: `/post/${postData.pid}`,
|
path: `/post/${postData.pid}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user