mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2026-05-18 13:13:18 -06:00
Make errors catchable and (de)register at config node of all nodes
This commit is contained in:
@@ -8,9 +8,10 @@ module.exports = function(RED) {
|
||||
this.server = RED.nodes.getNode(n.server);
|
||||
|
||||
if(!this.server) {
|
||||
node.error('Server must be configured on the node.');
|
||||
node.error('Server must be configured on the node.', {});
|
||||
return;
|
||||
}
|
||||
node.server.register(node);
|
||||
|
||||
this.encodeUri = function(pathTemplate, variables) {
|
||||
for (const key in variables) {
|
||||
@@ -41,12 +42,12 @@ module.exports = function(RED) {
|
||||
}
|
||||
|
||||
if(!node.server.isConnected()) {
|
||||
node.error("Matrix server connection is currently closed");
|
||||
node.error("Matrix server connection is currently closed", {});
|
||||
node.send([null, msg]);
|
||||
}
|
||||
|
||||
if(!msg.userId) {
|
||||
node.error("msg.userId must be set to edit/create a user (ex: @user:server.com)");
|
||||
node.error("msg.userId must be set to edit/create a user (ex: @user:server.com)", {});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,6 +71,10 @@ module.exports = function(RED) {
|
||||
node.send([null, msg]);
|
||||
});
|
||||
});
|
||||
|
||||
node.on("close", function() {
|
||||
node.server.deregister(node);
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("matrix-synapse-deactivate-user", MatrixSynapseDeactivateUser);
|
||||
}
|
||||
Reference in New Issue
Block a user