From 5f129560aaa7647e6f0aa6c231b774de61358bc1 Mon Sep 17 00:00:00 2001 From: Skylar Sadlier Date: Thu, 24 Mar 2022 13:56:42 -0600 Subject: [PATCH 1/4] Couple of little changes: - Fix matrix-receive message types displaying in uppercase when it should be lowercase - Readme updated with some extra things that are now possible since last release - Link to matrix.org project in our README.md --- README.md | 4 +++- src/matrix-receive.html | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bb78883..47c26e6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # node-red-contrib-matrix-chat -Matrix chat server client for [Node-RED](https://nodered.org/) +[Matrix](https://matrix.org/) chat server client for [Node-RED](https://nodered.org/) ***Currently we are in beta. We ask that you open any issues you have on our repository to help us reach a stable well tested version. Things may change & break before our first release so check changelog before updating.*** @@ -13,6 +13,8 @@ The following is supported from this package: - [Currently a WIP](#end-to-end-encryption-notes) - Receive events from a room (messages, reactions, images, and files) whether encrypted or not - Send Images/Files (sending files to e2ee room doesn't currently encrypt them yet) +- Edit messages +- Delete events (messages, reactions, etc) - Decrypt files in e2ee rooms - Send HTML/Plain Text Message/Notice - React to messages diff --git a/src/matrix-receive.html b/src/matrix-receive.html index 1b10fd7..76b4e5e 100644 --- a/src/matrix-receive.html +++ b/src/matrix-receive.html @@ -49,7 +49,7 @@ style="width: auto; margin-left: 125px; vertical-align: top" />
@@ -59,7 +59,7 @@ style="width: auto; margin-left: 125px; vertical-align: top" />
@@ -69,7 +69,7 @@ style="width: auto; margin-left: 125px; vertical-align: top" />
@@ -79,7 +79,7 @@ style="width: auto; margin-left: 125px; vertical-align: top" />
@@ -89,7 +89,7 @@ style="width: auto; margin-left: 125px; vertical-align: top" />
@@ -99,7 +99,7 @@ style="width: auto; margin-left: 125px; vertical-align: top" />
\ No newline at end of file diff --git a/src/matrix-receive.js b/src/matrix-receive.js index 81ac351..f69225b 100644 --- a/src/matrix-receive.js +++ b/src/matrix-receive.js @@ -11,7 +11,9 @@ module.exports = function(RED) { this.acceptStickers = n.acceptStickers; this.acceptReactions = n.acceptReactions; this.acceptFiles = n.acceptFiles; + this.acceptAudio = n.acceptAudio; this.acceptImages = n.acceptImages; + this.acceptLocations = n.acceptLocations; this.roomId = n.roomId; this.roomIds = this.roomId ? this.roomId.split(',') : []; @@ -72,6 +74,27 @@ module.exports = function(RED) { } break; + case 'm.audio': + if(!node.acceptAudio) return; + if(msg.encrypted) { + msg.url = node.server.matrixClient.mxcUrlToHttp(msg.content.file.url); + msg.mxc_url = msg.content.file.url; + } else { + msg.url = node.server.matrixClient.mxcUrlToHttp(msg.content.url); + msg.mxc_url = msg.content.url; + } + + if('org.matrix.msc1767.file' in msg.content) { + msg.filename = msg.content['org.matrix.msc1767.file'].name; + msg.mimetype = msg.content['org.matrix.msc1767.file'].mimetype; + } + + if('org.matrix.msc1767.audio' in msg.content) { + msg.duration = msg.content['org.matrix.msc1767.audio'].duration; + msg.waveform = msg.content['org.matrix.msc1767.audio'].waveform; + } + break; + case 'm.image': if(!node.acceptImages) return; msg.filename = msg.content.filename || msg.content.body; @@ -88,6 +111,12 @@ module.exports = function(RED) { } break; + case 'm.location': + if(!node.acceptLocations) return; + msg.geo_uri = msg.content.geo_uri; + msg.payload = msg.content.body; + break; + case 'm.reaction': if(!node.acceptReactions) return; msg.info = msg.content["m.relates_to"].info; From 5ef0b6a11fca445be8718b74d37af06cf7704fc2 Mon Sep 17 00:00:00 2001 From: Skylar Sadlier Date: Tue, 19 Apr 2022 12:58:52 -0600 Subject: [PATCH 3/4] Fix: Error thrown in folder migration if new and old path are same --- src/matrix-server-config.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/matrix-server-config.js b/src/matrix-server-config.js index 0403916..ea67b85 100644 --- a/src/matrix-server-config.js +++ b/src/matrix-server-config.js @@ -5,8 +5,6 @@ const { resolve } = require('path'); const { LocalStorage } = require('node-localstorage'); const { LocalStorageCryptoStore } = require('matrix-js-sdk/lib/crypto/store/localStorage-crypto-store'); const {RoomEvent, RoomMemberEvent, HttpApiEvent, ClientEvent} = require("matrix-js-sdk"); -const {deriveKey} = require("matrix-js-sdk/lib/crypto/key_passphrase"); -const {encryptAES} = require("matrix-js-sdk/lib/crypto/aes"); module.exports = function(RED) { function MatrixFolderNameFromUserId(name) { @@ -466,7 +464,7 @@ module.exports = function(RED) { fs.renameSync(oldStorageDir, oldStorageDir + "-backup"); } - if(RED.settings.userDir !== resolve('./')) { + if(RED.settings.userDir !== resolve('./') && resolve(oldStorageDir2) !== resolve(storageDir)) { // user directory does not match running directory // check if we stored stuff in wrong directory and move it if(fs.pathExistsSync(oldStorageDir2)){ From bd4f6ea48637077b671692140f7a9a4dc161aa5a Mon Sep 17 00:00:00 2001 From: Skylar Sadlier Date: Tue, 19 Apr 2022 13:01:00 -0600 Subject: [PATCH 4/4] Update version to 0.6.1 - Fix: Error thrown in folder migration if new and old path are same --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 090bf77..347d75b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-matrix-chat", - "version": "0.5.8", + "version": "0.6.1", "description": "Matrix chat server client for Node-RED", "dependencies": { "fs-extra": "^10.0.1",