mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +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 | 	// Add message to room | ||||||
| 	await messaging.sendMessage({ | 	const message = await messaging.sendMessage({ | ||||||
| 		mid: object.id, | 		mid: object.id, | ||||||
| 		uid: object.attributedTo, | 		uid: object.attributedTo, | ||||||
| 		roomId: roomId, | 		roomId: roomId, | ||||||
| @@ -268,6 +268,7 @@ Notes.assertPrivate = async (object) => { | |||||||
| 		timestamp: Date.now(), | 		timestamp: Date.now(), | ||||||
| 		// ip: caller.ip, | 		// ip: caller.ip, | ||||||
| 	}); | 	}); | ||||||
|  | 	messaging.notifyUsersInRoom(object.attributedTo, roomId, message); | ||||||
|  |  | ||||||
| 	// Set real timestamp back so that the message shows even though it predates room joining | 	// Set real timestamp back so that the message shows even though it predates room joining | ||||||
| 	await messaging.setMessageField(object.id, 'timestamp', timestamp); | 	await messaging.setMessageField(object.id, 'timestamp', timestamp); | ||||||
|   | |||||||
| @@ -90,8 +90,6 @@ module.exports = function (Messaging) { | |||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	async function sendNotification(fromUid, roomId, messageObj) { | 	async function sendNotification(fromUid, roomId, messageObj) { | ||||||
| 		fromUid = parseInt(fromUid, 10); |  | ||||||
|  |  | ||||||
| 		const [settings, roomData, realtimeUids] = await Promise.all([ | 		const [settings, roomData, realtimeUids] = await Promise.all([ | ||||||
| 			db.getObject(`chat:room:${roomId}:notification:settings`), | 			db.getObject(`chat:room:${roomId}:notification:settings`), | ||||||
| 			Messaging.getRoomData(roomId), | 			Messaging.getRoomData(roomId), | ||||||
| @@ -104,7 +102,7 @@ module.exports = function (Messaging) { | |||||||
| 			uids = uids.filter( | 			uids = uids.filter( | ||||||
| 				uid => utils.isNumber(uid) && | 				uid => utils.isNumber(uid) && | ||||||
| 					(parseInt((settings && settings[uid]) || roomDefault, 10) === ALLMESSAGES) && | 					(parseInt((settings && settings[uid]) || roomDefault, 10) === ALLMESSAGES) && | ||||||
| 					fromUid !== parseInt(uid, 10) && | 					String(fromUid) !== String(uid) && | ||||||
| 					!realtimeUids.includes(parseInt(uid, 10)) | 					!realtimeUids.includes(parseInt(uid, 10)) | ||||||
| 			); | 			); | ||||||
| 			const hasRead = await Messaging.hasRead(uids, roomId); | 			const hasRead = await Messaging.hasRead(uids, roomId); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user