1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

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> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name"> <input type="text" id="node-input-name" placeholder="Name">
</div> </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. the node will try to listen to all the rooms the user has access to.
</div> </div>
</script> </script>

View File

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