nodebb-plugin-mentions 4.3.1 → 4.3.3
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/library.js +17 -4
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -166,13 +166,26 @@ Mentions.notifyMessage = async (hookData) => {
|
|
|
166
166
|
getUidsToNotify(matches),
|
|
167
167
|
Messaging.getRoomData(roomId),
|
|
168
168
|
]);
|
|
169
|
-
if (!roomData || !matchedUids.length) {
|
|
169
|
+
if (!roomData || !matchedUids.length || !roomData.public) {
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
const
|
|
173
|
-
|
|
172
|
+
const io = require.main.require('./src/socket.io');
|
|
173
|
+
|
|
174
|
+
const [onlineUidsInRoom, isUserInRoom, notifSettings, checks] = await Promise.all([
|
|
175
|
+
io.getUidsInRoom(`chat_room_${roomId}`),
|
|
176
|
+
Messaging.isUsersInRoom(matchedUids, roomId),
|
|
177
|
+
Messaging.getUidsNotificationSetting(matchedUids, roomId),
|
|
178
|
+
Promise.all(matchedUids.map(
|
|
179
|
+
uid => !roomData.groups.length || Groups.isMemberOfAny(uid, roomData.groups)
|
|
180
|
+
)),
|
|
181
|
+
]);
|
|
182
|
+
|
|
183
|
+
const uidsToNotify = matchedUids.filter(
|
|
184
|
+
(uid, idx) => checks[idx] &&
|
|
185
|
+
isUserInRoom[idx] &&
|
|
186
|
+
!onlineUidsInRoom.includes(String(uid)) &&
|
|
187
|
+
notifSettings[idx] === Messaging.notificationSettings.ATMENTION
|
|
174
188
|
);
|
|
175
|
-
const uidsToNotify = matchedUids.filter((uid, idx) => checks[idx]);
|
|
176
189
|
if (!uidsToNotify.length) {
|
|
177
190
|
return;
|
|
178
191
|
}
|
package/package.json
CHANGED