From 40362ee985a52290883176acdde7c7def8cc844a Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 23 Feb 2021 12:45:55 +0000 Subject: [PATCH] Let xmpp in handle a list of rooms --- social/xmpp/92-xmpp.html | 1 + social/xmpp/92-xmpp.js | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/social/xmpp/92-xmpp.html b/social/xmpp/92-xmpp.html index 1b81a8ef..dbf3eb9a 100644 --- a/social/xmpp/92-xmpp.html +++ b/social/xmpp/92-xmpp.html @@ -19,6 +19,7 @@
Note: By leaving Buddy empty and ticking "Is a chat room", the node will try to listen to all the rooms the user has access to. + You can specify multiple rooms by separating them by a :
diff --git a/social/xmpp/92-xmpp.js b/social/xmpp/92-xmpp.js index d056ef51..ce6b90d9 100644 --- a/social/xmpp/92-xmpp.js +++ b/social/xmpp/92-xmpp.js @@ -322,7 +322,8 @@ module.exports = function(RED) { this.join = n.join || false; this.sendAll = n.sendObject; // Yes, it's called "from", don't ask me why; I don't know why - this.from = (n.to || "").trim(); + // (because it's where you are asking to get messages from...) + this.from = ((n.to || "").split(':')).map(s => s.trim()); this.quiet = false; // MUC == Multi-User-Chat == chatroom //this.muc = this.join && (this.from !== "") @@ -357,13 +358,15 @@ module.exports = function(RED) { node.quiet = false; node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"}); if (node.join) { - if (node.from === "") { + if (node.from[0] === "") { // try to get list of all rooms and join them all. getItems(this.serverConfig.server,this.serverConfig.id,xmpp); } else { // if we want to use a chatroom, we need to tell the server we want to join it - joinMUC(node, xmpp, node.from+'/'+node.nick); + for (var i=0; i