nodebb-plugin-mentions 4.8.7 → 4.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/languages/en_GB/notifications.json +2 -2
- package/library.js +14 -9
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"mentions": "Mentions",
|
|
3
|
-
"user-mentioned-you-in": "<strong>%1</strong> mentioned you<br/><strong>%2</strong>",
|
|
3
|
+
"user-mentioned-you-in": "<strong>%1</strong> mentioned you in <br/><strong>%2</strong>",
|
|
4
4
|
"user-mentioned-you-in-room": "<strong>%1</strong> mentioned you in <strong class=\"text-nowrap\"><i class=\"fa %2\"></i>%3</strong>",
|
|
5
|
-
"user-mentioned-group-in": "<strong>%1</strong> mentioned <strong>%2</strong
|
|
5
|
+
"user-mentioned-group-in": "<strong>%1</strong> mentioned <strong>%2</strong> in <br/><strong>%3</strong>",
|
|
6
6
|
"notificationType-mention": "When someone mentions you"
|
|
7
7
|
}
|
package/library.js
CHANGED
|
@@ -26,6 +26,7 @@ const slugify = require.main.require('./src/slugify');
|
|
|
26
26
|
const batch = require.main.require('./src/batch');
|
|
27
27
|
const utils = require.main.require('./src/utils');
|
|
28
28
|
const SocketPlugins = require.main.require('./src/socket.io/plugins');
|
|
29
|
+
const translator = require.main.require('./src/translator');
|
|
29
30
|
|
|
30
31
|
const utility = require('./lib/utility');
|
|
31
32
|
|
|
@@ -136,7 +137,6 @@ Mentions.notify = async function ({ post }) {
|
|
|
136
137
|
]);
|
|
137
138
|
const { displayname } = userData;
|
|
138
139
|
const title = entitiesDecode(topic.title);
|
|
139
|
-
const titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
|
140
140
|
|
|
141
141
|
let uids = uidsToNotify.filter(
|
|
142
142
|
uid => uid !== postOwner && !topicFollowers.includes(uid)
|
|
@@ -162,7 +162,8 @@ Mentions.notify = async function ({ post }) {
|
|
|
162
162
|
|
|
163
163
|
const filteredUids = await filterUidsAlreadyMentioned(uids, post.pid);
|
|
164
164
|
if (filteredUids.length) {
|
|
165
|
-
|
|
165
|
+
const notifText = translator.compile('notifications:user-mentioned-you-in', displayname, title);
|
|
166
|
+
await sendNotificationToUids(post, filteredUids, 'user', notifText);
|
|
166
167
|
await db.setAdd(`mentions:pid:${post.pid}:uids`, filteredUids);
|
|
167
168
|
}
|
|
168
169
|
|
|
@@ -172,7 +173,8 @@ Mentions.notify = async function ({ post }) {
|
|
|
172
173
|
const groupName = groupsToNotify[i].name;
|
|
173
174
|
const groupMentionSent = await db.isSetMember(`mentions:pid:${post.pid}:groups`, groupName);
|
|
174
175
|
if (!groupMentionSent && memberUids.length) {
|
|
175
|
-
|
|
176
|
+
const notifText = translator.compile('notifications:user-mentioned-group-in', displayname, groupName, title);
|
|
177
|
+
await sendNotificationToUids(post, memberUids, groupName, notifText);
|
|
176
178
|
await db.setAdd(`mentions:pid:${post.pid}:groups`, groupName);
|
|
177
179
|
}
|
|
178
180
|
}
|
|
@@ -198,11 +200,12 @@ Mentions.notifyMessage = async (hookData) => {
|
|
|
198
200
|
}
|
|
199
201
|
const io = require.main.require('./src/socket.io');
|
|
200
202
|
|
|
201
|
-
const [onlineUidsInRoom, fromUser, isUserInRoom, notifSettings, checks] = await Promise.all([
|
|
203
|
+
const [onlineUidsInRoom, fromUser, isUserInRoom, notifSettings, parsedMessage, checks] = await Promise.all([
|
|
202
204
|
io.getUidsInRoom(`chat_room_${roomId}`),
|
|
203
205
|
User.getUserFields(message.fromuid, ['username']),
|
|
204
206
|
Messaging.isUsersInRoom(matchedUids, roomId),
|
|
205
207
|
Messaging.getUidsNotificationSetting(matchedUids, roomId),
|
|
208
|
+
Messaging.parse(message.content, message.fromuid, 0, message.roomId, false),
|
|
206
209
|
Promise.all(matchedUids.map(
|
|
207
210
|
uid => !roomData.groups.length || Groups.isMemberOfAny(uid, roomData.groups)
|
|
208
211
|
)),
|
|
@@ -222,9 +225,9 @@ Mentions.notifyMessage = async (hookData) => {
|
|
|
222
225
|
const notifObj = await Notifications.create({
|
|
223
226
|
type: 'mention',
|
|
224
227
|
bodyShort: `[[notifications:user-mentioned-you-in-room, ${fromUser.displayname}, ${icon}, ${roomName}]]`,
|
|
225
|
-
bodyLong:
|
|
226
|
-
nid: `chat_${roomId}_${message.fromuid}_${message.
|
|
227
|
-
mid: message.
|
|
228
|
+
bodyLong: parsedMessage,
|
|
229
|
+
nid: `chat_${roomId}_${message.fromuid}_${message.mid}`,
|
|
230
|
+
mid: message.mid,
|
|
228
231
|
from: message.fromuid,
|
|
229
232
|
path: `/chats/${roomId}`,
|
|
230
233
|
importance: 6,
|
|
@@ -314,7 +317,10 @@ async function sendNotificationToUids(postData, uids, nidType, notificationText)
|
|
|
314
317
|
}
|
|
315
318
|
|
|
316
319
|
async function createNotification(postData, nidType, notificationText) {
|
|
317
|
-
|
|
320
|
+
// postData.sourceContent or postData.content is not parsed yet
|
|
321
|
+
// this is triggered from action:post.save or action:post.edit
|
|
322
|
+
await posts.parsePost(postData);
|
|
323
|
+
|
|
318
324
|
return await Notifications.create({
|
|
319
325
|
type: 'mention',
|
|
320
326
|
bodyShort: notificationText,
|
|
@@ -324,7 +330,6 @@ async function createNotification(postData, nidType, notificationText) {
|
|
|
324
330
|
tid: postData.tid,
|
|
325
331
|
from: postData.uid,
|
|
326
332
|
path: `/post/${encodeURIComponent(postData.pid)}`,
|
|
327
|
-
topicTitle: title ? utils.decodeHTMLEntities(title) : title,
|
|
328
333
|
importance: 6,
|
|
329
334
|
});
|
|
330
335
|
}
|
package/package.json
CHANGED