Fullname in notifications (#10157)

* init - fullname notifications setting

* fullname in topic reply

* fullname for group-request-membership

* fullname for group-leave notification

* fullname for new-post-flag & new-user-flag

* removed log

* fullname for user follow

* fullname in message notification

* fullname in follow

* fullname for sendNotificationToPostOwner

* fullname in sendNotificationToTopicOwner

* fullname in doExport

* shorthand name set

* shorter name set

* fullname in notifications

* displayname for notifications

* removed unused require
This commit is contained in:
Magnus
2022-01-19 16:19:11 +01:00
committed by GitHub
parent 857ac48021
commit 7bd3e31dec
9 changed files with 36 additions and 19 deletions

View File

@@ -80,18 +80,20 @@ SocketHelpers.sendNotificationToPostOwner = async function (pid, fromuid, comman
if (!canRead || isIgnoring[0] || !postData.uid || fromuid === postData.uid) {
return;
}
const [username, topicTitle, postObj] = await Promise.all([
user.getUserField(fromuid, 'username'),
const [userData, topicTitle, postObj] = await Promise.all([
user.getUserFields(fromuid, ['username']),
topics.getTopicField(postData.tid, 'title'),
posts.parsePost(postData),
]);
const { displayname } = userData;
const title = utils.decodeHTMLEntities(topicTitle);
const titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
const notifObj = await notifications.create({
type: command,
bodyShort: `[[${notification}, ${username}, ${titleEscaped}]]`,
bodyShort: `[[${notification}, ${displayname}, ${titleEscaped}]]`,
bodyLong: postObj.content,
pid: pid,
tid: postData.tid,
@@ -113,20 +115,23 @@ SocketHelpers.sendNotificationToTopicOwner = async function (tid, fromuid, comma
fromuid = parseInt(fromuid, 10);
const [username, topicData] = await Promise.all([
user.getUserField(fromuid, 'username'),
const [userData, topicData] = await Promise.all([
user.getUserFields(fromuid, ['username']),
topics.getTopicFields(tid, ['uid', 'slug', 'title']),
]);
if (fromuid === topicData.uid) {
return;
}
const { displayname } = userData;
const ownerUid = topicData.uid;
const title = utils.decodeHTMLEntities(topicData.title);
const titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
const notifObj = await notifications.create({
bodyShort: `[[${notification}, ${username}, ${titleEscaped}]]`,
bodyShort: `[[${notification}, ${displayname}, ${titleEscaped}]]`,
path: `/topic/${topicData.slug}`,
nid: `${command}:tid:${tid}:uid:${fromuid}`,
from: fromuid,

View File

@@ -93,8 +93,9 @@ module.exports = function (SocketUser) {
child.on('exit', async () => {
await db.deleteObjectField('locks', `export:${data.uid}${type}`);
const userData = await user.getUserFields(data.uid, ['username', 'userslug']);
const { displayname } = userData;
const n = await notifications.create({
bodyShort: `[[notifications:${type}-exported, ${userData.username}]]`,
bodyShort: `[[notifications:${type}-exported, ${displayname}]]`,
path: `/api/user/${userData.userslug}/export/${type}`,
nid: `${type}:export:${data.uid}`,
from: data.uid,