mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: notify users on new message from remote users, fix use of parseInt in generating chat notification
re: #12834
This commit is contained in:
@@ -259,7 +259,7 @@ Notes.assertPrivate = async (object) => {
|
||||
}
|
||||
|
||||
// Add message to room
|
||||
await messaging.sendMessage({
|
||||
const message = await messaging.sendMessage({
|
||||
mid: object.id,
|
||||
uid: object.attributedTo,
|
||||
roomId: roomId,
|
||||
@@ -268,6 +268,7 @@ Notes.assertPrivate = async (object) => {
|
||||
timestamp: Date.now(),
|
||||
// ip: caller.ip,
|
||||
});
|
||||
messaging.notifyUsersInRoom(object.attributedTo, roomId, message);
|
||||
|
||||
// Set real timestamp back so that the message shows even though it predates room joining
|
||||
await messaging.setMessageField(object.id, 'timestamp', timestamp);
|
||||
|
||||
@@ -90,8 +90,6 @@ module.exports = function (Messaging) {
|
||||
};
|
||||
|
||||
async function sendNotification(fromUid, roomId, messageObj) {
|
||||
fromUid = parseInt(fromUid, 10);
|
||||
|
||||
const [settings, roomData, realtimeUids] = await Promise.all([
|
||||
db.getObject(`chat:room:${roomId}:notification:settings`),
|
||||
Messaging.getRoomData(roomId),
|
||||
@@ -104,7 +102,7 @@ module.exports = function (Messaging) {
|
||||
uids = uids.filter(
|
||||
uid => utils.isNumber(uid) &&
|
||||
(parseInt((settings && settings[uid]) || roomDefault, 10) === ALLMESSAGES) &&
|
||||
fromUid !== parseInt(uid, 10) &&
|
||||
String(fromUid) !== String(uid) &&
|
||||
!realtimeUids.includes(parseInt(uid, 10))
|
||||
);
|
||||
const hasRead = await Messaging.hasRead(uids, roomId);
|
||||
|
||||
Reference in New Issue
Block a user