Skylar Sadlier 8bee386216 - Update version to 0.1.5
- Updated readme
- Support for e2ee is here! It's in beta as I am sure there are still things to do (such as adding a node for encrypting files as files currently are not encrypted).
- Added nodes for joining a room (and forcing users into a room), creating rooms, decrypting files, and inviting users to a room.
- matrix-synapse-register node name changed from "Synapse Register v1" to "Shared Secret Registration" to make it more self explanatory.
- matrix-receive node updated so that instead of selecting what events to ignore you select what events to listen on (this way it isn't a BC every time we add another event).
- matrix-receive now handles m.emote & m.sticker events
- matrix-server-config updated to now include the device ID and a checkbox to flag whether to enable e2ee support or not.
- matrix-synapse-create-edit-user.html updated to include link to the API docs'
- matrix-synapse-deactivate-user.html updated to include message about alternative way to deactivate users (in a way that is recoverable)
- matrix-synapse-register node does not need to display if connected or not since it users an entirely different API anyways
- matrix-synapse-users.html updated to include link to API docs
2021-08-23 10:17:08 -06:00

80 lines
2.4 KiB
JavaScript

module.exports = function(RED) {
function MatrixReact(n) {
RED.nodes.createNode(this, n);
var node = this;
this.name = n.name;
this.server = RED.nodes.getNode(n.server);
this.roomId = n.roomId;
if (!node.server) {
node.warn("No configuration node");
return;
}
node.status({ fill: "red", shape: "ring", text: "disconnected" });
node.server.on("disconnected", function(){
node.status({ fill: "red", shape: "ring", text: "disconnected" });
});
node.server.on("connected", function() {
node.status({ fill: "green", shape: "ring", text: "connected" });
});
node.on("input", function (msg) {
if (!node.server || !node.server.matrixClient) {
node.error("No matrix server selected");
return;
}
if(!node.server.isConnected()) {
node.error("Matrix server connection is currently closed");
node.send([null, msg]);
}
msg.topic = node.roomId || msg.topic;
if(!msg.topic) {
node.error("Room must be specified in msg.topic or in configuration");
return;
}
if(!msg.payload) {
node.error('msg.payload is required');
return;
}
let eventId = msg.referenceEventId || msg.eventId;
if(!eventId) {
node.error('Either msg.referenceEventId or msg.eventId must be defined to react to a message.');
return;
}
msg.type = 'm.reaction';
node.server.matrixClient.sendCompleteEvent(
msg.topic,
{
type: 'm.reaction',
content: {
"m.relates_to": {
event_id: eventId,
key: msg.payload,
rel_type: "m.annotation"
}
}
}
)
.then(function(e) {
msg.eventId = e.event_id;
node.send([msg, null]);
})
.catch(function(e){
msg.error = e;
node.send([null, msg]);
});
});
}
RED.nodes.registerType("matrix-react", MatrixReact);
}