mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2026-05-14 02:41:17 -06:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 54a9972bbc | |||
| ad34f018ab | |||
| 20345787d2 | |||
| 99c19923c6 | |||
| 093d59893e | |||
| 913f5dfcb9 | |||
| e0947dd3bc | |||
| 8287f3c08a | |||
| 2a78524a90 | |||
| d01838ac84 | |||
| 2059f8455d | |||
| 0cb8ecf8aa | |||
| 77f2c4be46 | |||
| cf82daf5da | |||
| 487241e097 |
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
Join our public Matrix room for help: [#node-red-contrib-matrix-chat:skylar.tech](https://app.element.io/#/room/#node-red-contrib-matrix-chat:skylar.tech)
|
Join our public Matrix room for help: [#node-red-contrib-matrix-chat:skylar.tech](https://app.element.io/#/room/#node-red-contrib-matrix-chat:skylar.tech)
|
||||||
|
|
||||||
|
[](https://ko-fi.com/B0B51BM7C)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
Supported functionality in this package includes:
|
Supported functionality in this package includes:
|
||||||
@@ -59,7 +61,9 @@ Interested in helping? Contributions to finalize E2EE support are welcome!
|
|||||||
|
|
||||||
This module includes a node to register users using the Synapse secret registration endpoint. It returns both an `access_token` and a `device_id`, perfect for setting up the bot.
|
This module includes a node to register users using the Synapse secret registration endpoint. It returns both an `access_token` and a `device_id`, perfect for setting up the bot.
|
||||||
|
|
||||||
[See how to register a user here](https://github.com/Skylar-Tech/node-red-contrib-matrix-chat/tree/master/examples#readme).
|
[Guide on registering a user via the web browser](https://skylar.tech/matrix-chat-bot-module-for-node-red/)
|
||||||
|
|
||||||
|
[Guide on registering using shared secret registration](https://github.com/Skylar-Tech/node-red-contrib-matrix-chat/tree/master/examples#readme) (for server owners)
|
||||||
|
|
||||||
### Other Packages
|
### Other Packages
|
||||||
|
|
||||||
@@ -69,4 +73,4 @@ This module includes a node to register users using the Synapse secret registrat
|
|||||||
|
|
||||||
We welcome all contributions! Please submit a pull request if you add a feature so the whole community can benefit.
|
We welcome all contributions! Please submit a pull request if you add a feature so the whole community can benefit.
|
||||||
|
|
||||||
**Sharing is caring!**
|
**Sharing is caring!**
|
||||||
|
|||||||
Generated
+133
-735
File diff suppressed because it is too large
Load Diff
+2
-3
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-matrix-chat",
|
"name": "node-red-contrib-matrix-chat",
|
||||||
"version": "0.8.0",
|
"version": "0.9.0",
|
||||||
"description": "Matrix chat server client for Node-RED",
|
"description": "Matrix chat server client for Node-RED",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"abort-controller": "^3.0.0",
|
"abort-controller": "^3.0.0",
|
||||||
@@ -9,12 +9,11 @@
|
|||||||
"got": "^12.0.2",
|
"got": "^12.0.2",
|
||||||
"image-size": "^1.0.2",
|
"image-size": "^1.0.2",
|
||||||
"isomorphic-webcrypto": "^2.3.8",
|
"isomorphic-webcrypto": "^2.3.8",
|
||||||
"matrix-js-sdk": "^28.0.0",
|
"matrix-js-sdk": "34.11.1",
|
||||||
"mime": "^3.0.0",
|
"mime": "^3.0.0",
|
||||||
"node-fetch": "^3.3.0",
|
"node-fetch": "^3.3.0",
|
||||||
"node-localstorage": "^2.2.1",
|
"node-localstorage": "^2.2.1",
|
||||||
"olm": "https://gitlab.matrix.org/matrix-org/olm/-/package_files/2572/download",
|
"olm": "https://gitlab.matrix.org/matrix-org/olm/-/package_files/2572/download",
|
||||||
"request": "^2.88.2",
|
|
||||||
"sharp": "^0.33.4",
|
"sharp": "^0.33.4",
|
||||||
"tmp": "^0.2.1",
|
"tmp": "^0.2.1",
|
||||||
"utf8": "^3.0.0"
|
"utf8": "^3.0.0"
|
||||||
|
|||||||
+10
-18
@@ -19,14 +19,18 @@
|
|||||||
},
|
},
|
||||||
oneditprepare: function() {
|
oneditprepare: function() {
|
||||||
$("#node-input-roomId").typedInput({
|
$("#node-input-roomId").typedInput({
|
||||||
type: this.roomIdType,
|
types: ['msg','flow','global','str'],
|
||||||
types:['msg','flow','global','str'],
|
typeField: "#node-input-roomId"
|
||||||
}).typedInput('value', this.roomIdValue);
|
});
|
||||||
|
$("#node-input-roomId").typedInput("type", this.roomIdType || "msg");
|
||||||
|
$("#node-input-roomId").typedInput("value", this.roomIdValue || "topic");
|
||||||
|
|
||||||
$("#node-input-eventId").typedInput({
|
$("#node-input-eventId").typedInput({
|
||||||
type: this.eventIdType,
|
types: ['msg','flow','global','str'],
|
||||||
types:['msg','flow','global','str'],
|
typeField: "#node-input-eventId"
|
||||||
}).typedInput('value', this.eventIdValue);
|
});
|
||||||
|
$("#node-input-eventId").typedInput("type", this.eventIdType || "msg");
|
||||||
|
$("#node-input-eventId").typedInput("value", this.eventIdValue || "eventId");
|
||||||
},
|
},
|
||||||
oneditsave: function() {
|
oneditsave: function() {
|
||||||
this.roomIdType = $("#node-input-roomId").typedInput('type');
|
this.roomIdType = $("#node-input-roomId").typedInput('type');
|
||||||
@@ -58,18 +62,6 @@
|
|||||||
<label for="node-input-eventId"><i class="fa fa-file"></i> Event ID</label>
|
<label for="node-input-eventId"><i class="fa fa-file"></i> Event ID</label>
|
||||||
<input type="text" id="node-input-eventId">
|
<input type="text" id="node-input-eventId">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(function(){
|
|
||||||
$("#node-input-roomId").on("keyup", function() {
|
|
||||||
if($(this).val() && !$(this).val().startsWith("!")) {
|
|
||||||
$("#node-input-roomId-error").html(`Room IDs start with exclamation point "!"<br />Example: !OGEhHVWSdvArJzumhm:matrix.org`).show();
|
|
||||||
} else {
|
|
||||||
$("#node-input-roomId-error").hide();
|
|
||||||
}
|
|
||||||
}).trigger('keyup');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" data-help-name="matrix-get-event">
|
<script type="text/html" data-help-name="matrix-get-event">
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
acceptOwnEvents: {"value": false},
|
acceptOwnEvents: {"value": false},
|
||||||
acceptText: {"value": true},
|
acceptText: {"value": true},
|
||||||
acceptEmotes: {"value": true},
|
acceptEmotes: {"value": true},
|
||||||
|
acceptNotices: {"value": true},
|
||||||
acceptStickers: {"value": true},
|
acceptStickers: {"value": true},
|
||||||
acceptReactions: {"value": true},
|
acceptReactions: {"value": true},
|
||||||
acceptFiles: {"value": true},
|
acceptFiles: {"value": true},
|
||||||
@@ -66,6 +67,16 @@
|
|||||||
Accept text <code style="text-transform: none;">m.text</code>
|
Accept text <code style="text-transform: none;">m.text</code>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row" style="margin-bottom:0;">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="node-input-acceptNotices"
|
||||||
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
||||||
|
/>
|
||||||
|
<label for="node-input-acceptNotices" style="width: auto">
|
||||||
|
Accept notices <code style="text-transform: none;">m.notice</code>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="form-row" style="margin-bottom:0;">
|
<div class="form-row" style="margin-bottom:0;">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ module.exports = function(RED) {
|
|||||||
this.acceptOwnEvents = n.acceptOwnEvents;
|
this.acceptOwnEvents = n.acceptOwnEvents;
|
||||||
this.acceptText = n.acceptText;
|
this.acceptText = n.acceptText;
|
||||||
this.acceptEmotes = n.acceptEmotes;
|
this.acceptEmotes = n.acceptEmotes;
|
||||||
|
this.acceptNotices = n.acceptNotices;
|
||||||
this.acceptStickers = n.acceptStickers;
|
this.acceptStickers = n.acceptStickers;
|
||||||
this.acceptReactions = n.acceptReactions;
|
this.acceptReactions = n.acceptReactions;
|
||||||
this.acceptFiles = n.acceptFiles;
|
this.acceptFiles = n.acceptFiles;
|
||||||
@@ -69,6 +70,10 @@ module.exports = function(RED) {
|
|||||||
if (!node.acceptEmotes) return;
|
if (!node.acceptEmotes) return;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'm.notice':
|
||||||
|
if (!node.acceptNotices) return;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'm.text':
|
case 'm.text':
|
||||||
if (!node.acceptText) return;
|
if (!node.acceptText) return;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(msgFormat === 'msg.format') {
|
if(msgFormat === 'msg.format') {
|
||||||
if(!msg.format) {
|
if(!Object.hasOwn(msg, 'format')) {
|
||||||
node.error("Message format is set to be passed in via msg.format but was not defined", msg);
|
node.error("Message format is set to be passed in via msg.format but was not defined", msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -202,4 +202,4 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("matrix-send-message", MatrixSendImage);
|
RED.nodes.registerType("matrix-send-message", MatrixSendImage);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,8 @@
|
|||||||
name: { value: null },
|
name: { value: null },
|
||||||
autoAcceptRoomInvites: { value: true },
|
autoAcceptRoomInvites: { value: true },
|
||||||
enableE2ee: { type: "checkbox", value: true },
|
enableE2ee: { type: "checkbox", value: true },
|
||||||
global: { type: "checkbox", value: true }
|
global: { type: "checkbox", value: true },
|
||||||
|
allowUnknownDevices: { type: "checkbox", value: false }
|
||||||
},
|
},
|
||||||
icon: "matrix.png",
|
icon: "matrix.png",
|
||||||
label: function() {
|
label: function() {
|
||||||
@@ -130,6 +131,20 @@
|
|||||||
<code style="white-space: normal;">let client = global.get("matrixClient['@bot:example.com']");</code>
|
<code style="white-space: normal;">let client = global.get("matrixClient['@bot:example.com']");</code>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="node-config-input-allowUnknownDevices"
|
||||||
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
||||||
|
/>
|
||||||
|
<label for="node-config-input-allowUnknownDevices" style="width: auto">
|
||||||
|
Allow unverified devices in rooms
|
||||||
|
</label>
|
||||||
|
<div class="form-tips" style="margin-bottom: 12px;">
|
||||||
|
Allow sending messages to a room with unknown devices which have not been verified.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$("#matrix-login-btn").on("click", function() {
|
$("#matrix-login-btn").on("click", function() {
|
||||||
function prettyPrintJson(json) {
|
function prettyPrintJson(json) {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ const { resolve } = require('path');
|
|||||||
const { LocalStorage } = require('node-localstorage');
|
const { LocalStorage } = require('node-localstorage');
|
||||||
const { LocalStorageCryptoStore } = require('matrix-js-sdk/lib/crypto/store/localStorage-crypto-store');
|
const { LocalStorageCryptoStore } = require('matrix-js-sdk/lib/crypto/store/localStorage-crypto-store');
|
||||||
const {RoomEvent, RoomMemberEvent, HttpApiEvent, ClientEvent, MemoryStore} = require("matrix-js-sdk");
|
const {RoomEvent, RoomMemberEvent, HttpApiEvent, ClientEvent, MemoryStore} = require("matrix-js-sdk");
|
||||||
const request = require("request");
|
|
||||||
require("abort-controller/polyfill"); // polyfill abort-controller if we don't have it
|
require("abort-controller/polyfill"); // polyfill abort-controller if we don't have it
|
||||||
if (!globalThis.fetch) {
|
if (!globalThis.fetch) {
|
||||||
// polyfill fetch if we don't have it
|
// polyfill fetch if we don't have it
|
||||||
@@ -56,6 +55,7 @@ module.exports = function(RED) {
|
|||||||
this.autoAcceptRoomInvites = n.autoAcceptRoomInvites;
|
this.autoAcceptRoomInvites = n.autoAcceptRoomInvites;
|
||||||
this.e2ee = n.enableE2ee || false;
|
this.e2ee = n.enableE2ee || false;
|
||||||
this.globalAccess = n.global;
|
this.globalAccess = n.global;
|
||||||
|
this.allowUnknownDevices = n.allowUnknownDevices || false;
|
||||||
this.initializedAt = new Date();
|
this.initializedAt = new Date();
|
||||||
node.initialSyncLimit = 25;
|
node.initialSyncLimit = 25;
|
||||||
|
|
||||||
@@ -153,8 +153,7 @@ module.exports = function(RED) {
|
|||||||
localStorage: localStorage,
|
localStorage: localStorage,
|
||||||
}),
|
}),
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
deviceId: (this.deviceId || getStoredDeviceId(localStorage)) || undefined,
|
deviceId: (this.deviceId || getStoredDeviceId(localStorage)) || undefined
|
||||||
request
|
|
||||||
// verificationMethods: ["m.sas.v1"]
|
// verificationMethods: ["m.sas.v1"]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -401,6 +400,7 @@ module.exports = function(RED) {
|
|||||||
node.log("Initializing crypto...");
|
node.log("Initializing crypto...");
|
||||||
await node.matrixClient.initCrypto();
|
await node.matrixClient.initCrypto();
|
||||||
node.matrixClient.getCrypto().globalBlacklistUnverifiedDevices = false; // prevent errors from unverified devices
|
node.matrixClient.getCrypto().globalBlacklistUnverifiedDevices = false; // prevent errors from unverified devices
|
||||||
|
node.matrixClient.getCrypto().globalErrorOnUnknownDevices = !node.allowUnknownDevices;
|
||||||
}
|
}
|
||||||
node.log("Connecting to Matrix server...");
|
node.log("Connecting to Matrix server...");
|
||||||
await node.matrixClient.startClient({
|
await node.matrixClient.startClient({
|
||||||
@@ -479,8 +479,7 @@ module.exports = function(RED) {
|
|||||||
baseUrl: baseUrl,
|
baseUrl: baseUrl,
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
timelineSupport: true,
|
timelineSupport: true,
|
||||||
localTimeoutMs: '30000',
|
localTimeoutMs: '30000'
|
||||||
request
|
|
||||||
});
|
});
|
||||||
|
|
||||||
new TimelineWindow()
|
new TimelineWindow()
|
||||||
|
|||||||
Reference in New Issue
Block a user