Add resource and separate out domain in XMPP node

to address #881
This commit is contained in:
Dave Conway-Jones 2022-06-29 10:06:24 +01:00
parent 8431e624f7
commit 4cfbc6a32a
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
3 changed files with 16 additions and 5 deletions

View File

@ -157,13 +157,17 @@
<input type="text" id="node-config-input-user" placeholder="joe@blah.im">
</div>
<div class="form-row">
<label for="node-config-input-nickname"><i class="fa fa-user"></i> Nickname</label>
<label for="node-config-input-nickname"><i class="fa fa-heart"></i> Nickname</label>
<input type="text" id="node-config-input-nickname" placeholder="Joe (optional)">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label>
<input type="password" id="node-config-input-password">
</div>
<div class="form-row">
<label for="node-config-input-resource"><i class="fa fa-globe"></i> Resource</label>
<input type="text" id="node-config-input-resource" placeholder="optional resource id">
</div>
</script>
<script type="text/javascript">
@ -173,7 +177,8 @@
server: {value:"", required:false},
port: {value:5222, required:false, validate:RED.validators.number()},
user: {value:""},
nickname: {value:""}
nickname: {value:""},
resource: {value:""}
},
credentials: {
password: {type:"password"}

View File

@ -30,6 +30,8 @@ module.exports = function(RED) {
else {
this.port = parseInt(n.port);
}
this.domain = this.jid.split('@')[1] || this.server;
this.resource = n.resource || "";
// The password is obfuscated and stored in a separate location
var credentials = this.credentials;
@ -45,12 +47,16 @@ module.exports = function(RED) {
if (RED.settings.verbose || LOGITALL) {
this.log("Setting up connection xmpp: {service: "+proto+"://"+this.server+":"+this.port+", username: "+this.username+", password: "+this.password+"}");
}
this.client = client({
var opts = {
service: proto+'://' + this.server + ':' + this.port,
domain: this.domain,
username: this.username,
password: this.password,
timeout: 60000
});
}
if (this.resource !== "") { opts.resource = this.resource; }
console.log("OPTS",opts)
this.client = client(opts);
this.client.timeout = 60000;
// helper variable for checking against later, maybe we should be using the client

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-xmpp",
"version": "0.5.10",
"version": "0.6.0",
"description": "A Node-RED node to talk to an XMPP server",
"dependencies": {
"@xmpp/client": "^0.13.1"