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

remove xmpp surplus error messages

This commit is contained in:
Dave Conway-Jones 2021-06-09 22:28:34 +01:00
parent f35e4baaef
commit cf310adb07
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
3 changed files with 45 additions and 29 deletions

View File

@ -170,9 +170,9 @@
RED.nodes.registerType('xmpp-server',{
category: 'config',
defaults: {
server: {required:false},
port: {value:5222,required:false,validate:RED.validators.number()},
user: {type:"text"},
server: {value:"", required:false},
port: {value:5222, required:false, validate:RED.validators.number()},
user: {value:""},
nickname: {value:""}
},
credentials: {

View File

@ -9,7 +9,13 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n);
this.nickname = n.nickname;
this.jid = n.user;
this.username = n.user.split('@')[0];
if (this.jid.match(/\@/)) {
this.username = n.user.split('@')[0];
}
else {
this.username = n.user;
this.jid = n.user+'@'+n.server;
}
// The user may elect to just specify the jid in the settings,
// in which case extract the server from the jid and default the port
if ("undefined" === typeof n.server || n.server === "") {
@ -477,19 +483,24 @@ module.exports = function(RED) {
reas = error.toString().split('><')[1].split(" xml")[0].trim();
if (reas == "registration-required") { reas = "membership-required"; }
}
catch(e) {}
var msg = {
topic:stanza.attrs.from,
payload: {
code:error.attrs.code,
status:"error",
reason:reas,
name:node.serverConfig.MUCs[stanza.attrs.from.split('/')[0]]
}
};
node.send([null,msg]);
node.status({fill:"red",shape:"ring",text:"error : "+error.attrs.code+", "+error.attrs.type+", "+reas});
node.error(error.attrs.type+" error. "+error.attrs.code+" "+reas,msg);
catch(e) { }
if (error.attrs.code !== '404' && (error.attrs.code !== '400' && error.attrs.type !== 'wait')) {
var msg = {
topic:stanza.attrs.from,
payload: {
code:error.attrs.code,
status:"error",
reason:reas,
name:node.serverConfig.MUCs[stanza.attrs.from.split('/')[0]]
}
};
node.send([null,msg]);
node.status({fill:"red",shape:"ring",text:"error : "+error.attrs.code+", "+error.attrs.type+", "+reas});
node.error(error.attrs.type+" error. "+error.attrs.code+" "+reas,msg);
}
else {
// ignore 404 error
}
}
}
@ -701,17 +712,22 @@ module.exports = function(RED) {
if (reas == "registration-required") { reas = "membership-required"; }
}
catch(e) {}
var msg = {
topic:stanza.attrs.from,
payload: {
code:error.attrs.code,
status:"error",
reason:reas,
name:node.serverConfig.MUCs[stanza.attrs.from.split('/')[0]]
}
};
node.status({fill:"red",shape:"ring",text:"error : "+error.attrs.code+", "+error.attrs.type+", "+reas});
node.error(error.attrs.type+" error. "+error.attrs.code+" "+reas,msg);
if (error.attrs.code !== '404' && (error.attrs.code !== '400' && error.attrs.type !== 'wait')) {
var msg = {
topic:stanza.attrs.from,
payload: {
code:error.attrs.code,
status:"error",
reason:reas,
name:node.serverConfig.MUCs[stanza.attrs.from.split('/')[0]]
}
};
node.status({fill:"red",shape:"ring",text:"error : "+error.attrs.code+", "+error.attrs.type+", "+reas});
node.error(error.attrs.type+" error. "+error.attrs.code+" "+reas,msg);
}
else {
// ignore 404 error
}
}
}
});

View File

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