From 908d60835dcb33e1d116523c3bfe1c120a5d290b Mon Sep 17 00:00:00 2001 From: Marco Jakobs Date: Fri, 25 Nov 2022 20:56:06 +0100 Subject: [PATCH] Pass invites to the receive object This commit passes a room invite to the receive node, so you can react to it. Sample invitation: HDsvcHGiTYFxxxxxxx:mydomain.de : msg : Object object type: "r.invite" payload: "Invitation" userId: "@relay:mydomain.de" topic: "!HDsvcHGiTYFxxxxxxx:mydomain.de" _msgid: "ef1fd7f3c8ae82e6" --- src/matrix-receive.js | 6 ++++++ src/matrix-server-config.js | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/matrix-receive.js b/src/matrix-receive.js index f69225b..27c7ce9 100644 --- a/src/matrix-receive.js +++ b/src/matrix-receive.js @@ -32,6 +32,12 @@ module.exports = function(RED) { node.status({ fill: "green", shape: "ring", text: "connected" }); }); + + node.server.on("Room.invite", async function(msg) { + node.send(msg); + }); + + node.server.on("Room.timeline", async function(event, room, toStartOfTimeline, removed, data, msg) { // if node has a room ID set we only listen on that room if(node.roomIds.length && node.roomIds.indexOf(room.roomId) === -1) { diff --git a/src/matrix-server-config.js b/src/matrix-server-config.js index ea67b85..8b54b53 100644 --- a/src/matrix-server-config.js +++ b/src/matrix-server-config.js @@ -239,6 +239,13 @@ module.exports = function(RED) { }); } else { node.log("Got invite to join room " + member.roomId); + let msg = { + type : 'r.invite', + payload : 'Invitation', + userId : member.userId, + topic : member.roomId + }; + node.emit("Room.invite", msg); } } });