nodebb-plugin-mentions 4.3.1 → 4.3.2

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.
Files changed (2) hide show
  1. package/library.js +13 -4
  2. package/package.json +1 -1
package/library.js CHANGED
@@ -166,13 +166,22 @@ 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 checks = await Promise.all(
173
- matchedUids.map(uid => !roomData.groups.length || Groups.isMemberOfAny(uid, roomData.groups))
172
+ const io = require.main.require('./src/socket.io');
173
+
174
+ const [onlineUidsInRoom, isUserInRoom, checks] = await Promise.all([
175
+ io.getUidsInRoom(`chat_room_${roomId}`),
176
+ Messaging.isUsersInRoom(matchedUids, roomId),
177
+ Promise.all(matchedUids.map(
178
+ uid => !roomData.groups.length || Groups.isMemberOfAny(uid, roomData.groups)
179
+ )),
180
+ ]);
181
+
182
+ const uidsToNotify = matchedUids.filter(
183
+ (uid, idx) => checks[idx] && isUserInRoom[idx] && !onlineUidsInRoom.includes(String(uid))
174
184
  );
175
- const uidsToNotify = matchedUids.filter((uid, idx) => checks[idx]);
176
185
  if (!uidsToNotify.length) {
177
186
  return;
178
187
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-mentions",
3
- "version": "4.3.1",
3
+ "version": "4.3.2",
4
4
  "description": "NodeBB Plugin that allows users to mention other users by prepending an '@' sign to their username",
5
5
  "main": "library.js",
6
6
  "scripts": {