diff --git a/src/matrix-mark-read.html b/src/matrix-mark-read.html index e74f899..98848b0 100644 --- a/src/matrix-mark-read.html +++ b/src/matrix-mark-read.html @@ -64,191 +64,35 @@ \ No newline at end of file + +

Outputs

+ + +

Usage

+

This node dynamically reads the room ID and event ID from the message or other properties using typed inputs, allowing you to configure where the values are sourced from. It retrieves the corresponding event and sends a "read" receipt to the Matrix server to mark the event as read. If successful, it will trigger the first output. If an error occurs (e.g., the event or room is not found), the second output is triggered with the error message.

+ diff --git a/src/matrix-mark-read.js b/src/matrix-mark-read.js index f9559ca..bc8eebe 100644 --- a/src/matrix-mark-read.js +++ b/src/matrix-mark-read.js @@ -56,7 +56,17 @@ module.exports = function(RED) { let roomId = getToValue(msg, node.roomType, node.roomValue), eventId = getToValue(msg, node.eventIdType, node.eventIdValue); - msg.payload = await node.server.matrixClient.setRoomReadMarkers(roomId, eventId); + const room = node.server.matrixClient.getRoom(roomId); + if (!room) { + throw new Error(`Room ${roomId} not found.`); + } + + const event = room.findEventById(eventId); + if (!event) { + throw new Error(`Event ${eventId} not found in room ${roomId}.`); + } + + await node.server.matrixClient.sendReceipt(event, "m.read") node.send([msg, null]); } catch(e) { msg.error = `Room pagination error: ${e}`;