fix: closes #11249, notification uses displayname

isekai-main
Barış Soner Uşaklı 2 years ago
parent b5598a6e5d
commit 705cd13ad3

@ -87,14 +87,15 @@ function unpin(tid, topicData) {
} }
async function sendNotifications(uids, topicsData) { async function sendNotifications(uids, topicsData) {
const usernames = await Promise.all(uids.map(uid => user.getUserField(uid, 'username'))); const userData = await user.getUsersData(uids);
const uidToUsername = Object.fromEntries(uids.map((uid, idx) => [uid, usernames[idx]])); const uidToUserData = Object.fromEntries(uids.map((uid, idx) => [uid, userData[idx]]));
const postsData = await posts.getPostsData(topicsData.map(({ mainPid }) => mainPid)); const postsData = await posts.getPostsData(topicsData.map(t => t && t.mainPid));
postsData.forEach((postData, idx) => { postsData.forEach((postData, idx) => {
postData.user = {}; if (postData) {
postData.user.username = uidToUsername[postData.uid]; postData.user = uidToUserData[topicsData[idx].uid];
postData.topic = topicsData[idx]; postData.topic = topicsData[idx];
}
}); });
return Promise.all(topicsData.map( return Promise.all(topicsData.map(

Loading…
Cancel
Save