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',{ RED.nodes.registerType('xmpp-server',{
category: 'config', category: 'config',
defaults: { defaults: {
server: {required:false}, server: {value:"", required:false},
port: {value:5222,required:false,validate:RED.validators.number()}, port: {value:5222, required:false, validate:RED.validators.number()},
user: {type:"text"}, user: {value:""},
nickname: {value:""} nickname: {value:""}
}, },
credentials: { credentials: {

View File

@ -9,7 +9,13 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n); RED.nodes.createNode(this,n);
this.nickname = n.nickname; this.nickname = n.nickname;
this.jid = n.user; 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, // 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 // in which case extract the server from the jid and default the port
if ("undefined" === typeof n.server || n.server === "") { if ("undefined" === typeof n.server || n.server === "") {
@ -477,19 +483,24 @@ module.exports = function(RED) {
reas = error.toString().split('><')[1].split(" xml")[0].trim(); reas = error.toString().split('><')[1].split(" xml")[0].trim();
if (reas == "registration-required") { reas = "membership-required"; } if (reas == "registration-required") { reas = "membership-required"; }
} }
catch(e) {} catch(e) { }
var msg = { if (error.attrs.code !== '404' && (error.attrs.code !== '400' && error.attrs.type !== 'wait')) {
topic:stanza.attrs.from, var msg = {
payload: { topic:stanza.attrs.from,
code:error.attrs.code, payload: {
status:"error", code:error.attrs.code,
reason:reas, status:"error",
name:node.serverConfig.MUCs[stanza.attrs.from.split('/')[0]] 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.send([null,msg]);
node.error(error.attrs.type+" error. "+error.attrs.code+" "+reas,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"; } if (reas == "registration-required") { reas = "membership-required"; }
} }
catch(e) {} catch(e) {}
var msg = { if (error.attrs.code !== '404' && (error.attrs.code !== '400' && error.attrs.type !== 'wait')) {
topic:stanza.attrs.from, var msg = {
payload: { topic:stanza.attrs.from,
code:error.attrs.code, payload: {
status:"error", code:error.attrs.code,
reason:reas, status:"error",
name:node.serverConfig.MUCs[stanza.attrs.from.split('/')[0]] 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); 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", "name": "node-red-node-xmpp",
"version": "0.5.3", "version": "0.5.4",
"description": "A Node-RED node to talk to an XMPP server", "description": "A Node-RED node to talk to an XMPP server",
"dependencies": { "dependencies": {
"@xmpp/client": "^0.12.0" "@xmpp/client": "^0.12.0"