- Fix error with matrix-synapse-register node

- Ensure matrix-server-config's register/deregister methods are always available
This commit is contained in:
Skylar Sadlier 2023-10-14 22:26:29 -06:00
parent 9661922f78
commit c920dd12cb
2 changed files with 9 additions and 10 deletions

View File

@ -17,6 +17,7 @@ if (!globalThis.fetch) {
} }
module.exports = function(RED) { module.exports = function(RED) {
console.log(RED.settings.contextStorage);
// disable logging if set to "off" // disable logging if set to "off"
let loggingSettings = RED.settings.get('logging'); let loggingSettings = RED.settings.get('logging');
if( if(
@ -57,6 +58,14 @@ module.exports = function(RED) {
this.globalAccess = n.global; this.globalAccess = n.global;
this.initializedAt = new Date(); this.initializedAt = new Date();
// Keep track of all consumers of this node to be able to catch errors
node.register = function(consumerNode) {
node.users[consumerNode.id] = consumerNode;
};
node.deregister = function(consumerNode) {
delete node.users[consumerNode.id];
};
if(!this.userId) { if(!this.userId) {
node.log("Matrix connection failed: missing user ID in configuration."); node.log("Matrix connection failed: missing user ID in configuration.");
return; return;
@ -424,14 +433,6 @@ module.exports = function(RED) {
} }
) )
})(); })();
// Keep track of all consumers of this node to be able to catch errors
node.register = function(consumerNode) {
node.users[consumerNode.id] = consumerNode;
};
node.deregister = function(consumerNode) {
delete node.users[consumerNode.id];
};
} }
} }

View File

@ -21,8 +21,6 @@ module.exports = function(RED) {
return; return;
} }
node.server.register(node);
node.on("input", async function (msg) { node.on("input", async function (msg) {
const { got } = await import('got'); const { got } = await import('got');