xmpp node - use empty field to signify all rooms

This commit is contained in:
Dave Conway-Jones 2021-02-23 11:37:53 +00:00
parent 3ad829d75a
commit 7485760db9
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 9 additions and 9 deletions

View File

@ -17,7 +17,7 @@
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips"><b>Note:</b> By setting Buddy to "ALL_ROOMS" and ticking "Is a chat room",
<div class="form-tips"><b>Note:</b> 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.
</div>
</script>

View File

@ -322,10 +322,10 @@ 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 || "";
this.from = (n.to || "").trim();
this.quiet = false;
// MUC == Multi-User-Chat == chatroom
this.muc = this.join && (this.from !== "")
//this.muc = this.join && (this.from !== "")
// list of possible rooms - queried from server
this.roomsFound = {};
var node = this;
@ -356,8 +356,8 @@ module.exports = function(RED) {
xmpp.on('online', async address => {
node.quiet = false;
node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
if (node.muc) {
if (node.from.toUpperCase() === "ALL_ROOMS") {
if (node.join) {
if (node.from === "") {
// try to get list of all rooms and join them all.
getItems(this.serverConfig.server,this.serverConfig.id,xmpp);
}
@ -428,11 +428,11 @@ module.exports = function(RED) {
payload = body.getText();
}
var msg = { topic:from, payload:payload, room:conference };
if (from && stanza.attrs.from != node.nick && from != node.nick) {
if (node.from.toUpperCase() === "ALL_ROOMS" || node.from === conference) {
node.send([msg,null]);
}
//if (from && stanza.attrs.from != node.nick && from != node.nick) {
if (from && node.join && (node.from === "" || node.from === conference)) {
node.send([msg,null]);
}
//}
}
}
else if (stanza.is('presence')) {