mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2026-05-23 15:43:33 -06:00
Fix module compatibility with Node.js < 22
This commit is contained in:
+12
-13
@@ -1,9 +1,8 @@
|
||||
const {TimelineWindow, RelationType, Filter} = require("matrix-js-sdk");
|
||||
const crypto = require('crypto');
|
||||
module.exports = function(RED) {
|
||||
function MatrixReceiveMessage(n) {
|
||||
RED.nodes.createNode(this, n);
|
||||
|
||||
module.exports = function(RED) {
|
||||
function MatrixMarkRead(n) {
|
||||
RED.nodes.createNode(this, n);
|
||||
let node = this;
|
||||
this.name = n.name;
|
||||
this.server = RED.nodes.getNode(n.server);
|
||||
@@ -29,7 +28,7 @@ module.exports = function(RED) {
|
||||
});
|
||||
|
||||
node.on("input", async function (msg) {
|
||||
if (! node.server || ! node.server.matrixClient) {
|
||||
if (!node.server || !node.server.matrixClient) {
|
||||
node.error("No matrix server selected", msg);
|
||||
return;
|
||||
}
|
||||
@@ -38,15 +37,15 @@ module.exports = function(RED) {
|
||||
let value = property;
|
||||
if (type === "msg") {
|
||||
value = RED.util.getMessageProperty(msg, property);
|
||||
} else if ((type === 'flow') || (type === 'global')) {
|
||||
} else if (type === 'flow' || type === 'global') {
|
||||
try {
|
||||
value = RED.util.evaluateNodeProperty(property, type, node, msg);
|
||||
} catch(e2) {
|
||||
} catch (e2) {
|
||||
throw new Error("Invalid value evaluation");
|
||||
}
|
||||
} else if(type === "bool") {
|
||||
} else if (type === "bool") {
|
||||
value = (property === 'true');
|
||||
} else if(type === "num") {
|
||||
} else if (type === "num") {
|
||||
value = Number(property);
|
||||
}
|
||||
return value;
|
||||
@@ -66,9 +65,9 @@ module.exports = function(RED) {
|
||||
throw new Error(`Event ${eventId} not found in room ${roomId}.`);
|
||||
}
|
||||
|
||||
await node.server.matrixClient.sendReceipt(event, "m.read")
|
||||
await node.server.matrixClient.sendReceipt(event, "m.read");
|
||||
node.send([msg, null]);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
msg.error = `Room pagination error: ${e}`;
|
||||
node.error(msg.error, msg);
|
||||
node.send([null, msg]);
|
||||
@@ -79,5 +78,5 @@ module.exports = function(RED) {
|
||||
node.server.deregister(node);
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("matrix-mark-read", MatrixReceiveMessage);
|
||||
}
|
||||
RED.nodes.registerType("matrix-mark-read", MatrixMarkRead);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user