mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2025-04-19 04:23:08 -06:00
- change all references from msg.roomId to msg.topic to conform to Node-RED standards. - Added node for listing Synapse users server-wide (as long as the caller is an admin) - Events for Room.timeline are now handled by the server-config node and node's that listen for it bind a listener to that instead of the matrix client. - Added kick and ban nodes for kicking/banning from a room - Added node for fetching synapse user list using synapse admin API - Added node for fetching whois data from a user using Matrix admin API - Added node for deactivating users using the Synapse admin API - Can register users using the Synapse admin endpoint v1 (yay legacy) - Can add users using the Synapse admin endpoint v2 - Add more info to the readme.
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
module.exports = function(RED) {
|
|
function MatrixRoomUsers(n) {
|
|
RED.nodes.createNode(this, n);
|
|
|
|
var node = this;
|
|
|
|
this.name = n.name;
|
|
this.server = RED.nodes.getNode(n.server);
|
|
this.roomId = n.roomId;
|
|
this.contentType = n.contentType;
|
|
|
|
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.warn("No matrix server selected");
|
|
return;
|
|
}
|
|
|
|
if(!node.server.isConnected()) {
|
|
node.error("Matrix server connection is currently closed");
|
|
node.send([null, msg]);
|
|
}
|
|
|
|
let roomId = node.roomId || msg.topic;
|
|
if(!roomId) {
|
|
node.error("msg.topic is required. Specify in the input or configure the room ID on the node.");
|
|
return;
|
|
}
|
|
|
|
let queryParams = {
|
|
'from': msg.from || 0,
|
|
'limit': msg.limit || 100
|
|
};
|
|
|
|
if(msg.guests) {
|
|
queryParams['guests'] = msg.guests;
|
|
}
|
|
|
|
if(msg.order_by) {
|
|
queryParams['order_by'] = msg.order_by;
|
|
}
|
|
|
|
node.server.matrixClient
|
|
.getJoinedRoomMembers(roomId)
|
|
.then(function(e){
|
|
msg.payload = e;
|
|
node.send([msg, null]);
|
|
}).catch(function(e){
|
|
node.warn("Error fetching room user list " + e);
|
|
msg.error = e;
|
|
node.send([null, msg]);
|
|
});
|
|
});
|
|
}
|
|
RED.nodes.registerType("matrix-room-users", MatrixRoomUsers);
|
|
} |