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.
Files changed (2) hide show
  1. package/library.js +17 -4
  2. 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 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, 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-mentions",
3
- "version": "4.3.1",
3
+ "version": "4.3.3",
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": {