From 7bdadc0fe9fa9481a8adc6e870321dab17f3e30d Mon Sep 17 00:00:00 2001 From: Skylar Sadlier Date: Mon, 28 Mar 2022 00:39:48 -0600 Subject: [PATCH] Closes #209 - Can now receive audio files - Can now receive locations - Readme updated --- README.md | 2 +- src/matrix-receive.html | 61 +++++++++++++++++++++++++++++++++++++++++ src/matrix-receive.js | 29 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 47c26e6..384ccfa 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The following is supported from this package: - End-to-end encryption - [Currently a WIP](#end-to-end-encryption-notes) -- Receive events from a room (messages, reactions, images, and files) whether encrypted or not +- Receive events from a room (messages, reactions, images, audio, locations, 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) diff --git a/src/matrix-receive.html b/src/matrix-receive.html index 76b4e5e..0bd4062 100644 --- a/src/matrix-receive.html +++ b/src/matrix-receive.html @@ -15,7 +15,9 @@ acceptStickers: {"value": true}, acceptReactions: {"value": true}, acceptFiles: {"value": true}, + acceptAudio: {"value": true}, acceptImages: {"value": true}, + acceptLocations: {"value": true}, }, label: function() { return this.name || "Matrix Receive"; @@ -92,6 +94,16 @@ Accept files m.file +
+ + +
m.image
+
+ + +
\ 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;