diff --git a/README.md b/README.md
index b2b4dfa..f70d2ac 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ npm install node-red-contrib-matrix-chat
### End-to-End Encryption Notes
Currently this module has no way of getting encryption keys from other devices on the same account. Therefore it is recommended you use the bot exclusively with Node-RED after it's creation. Failure to do so will lead to your bot being unable to receive messages from e2ee rooms it joined from another client. Shared secret registration makes this super easy since it returns a token and device ID.
-This module stores a folder in your Node-RED directory called `matrix-local-storage` and is it vital that you periodically back this up if you are using e2ee. This is where the client stores all the keys necessary to decrypt messages and if lost you will lose access to e2e rooms. If you move your client to another NR install make sure to migrate this folder as well (and do not let both the old and new client run at same time).
+This module stores a folder in your Node-RED directory called `matrix-client-storage` and is it vital that you periodically back this up if you are using e2ee. This is where the client stores all the keys necessary to decrypt messages and if lost you will lose access to e2e rooms. If you move your client to another NR install make sure to migrate this folder as well (and do not let both the old and new client run at same time).
Want to contribute? Any help on getting the last pieces of e2ee figured out would be greatly appreciated :)
diff --git a/package-lock.json b/package-lock.json
index 6973054..c42198f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,21 +1,20 @@
{
"name": "node-red-contrib-matrix-chat",
- "version": "0.0.5",
+ "version": "0.1.8",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
- "version": "0.0.5",
+ "version": "0.1.8",
"license": "SEE LICENSE FILE",
"dependencies": {
+ "fs-extra": "^9.1.0",
"got": "^11.8.2",
"isomorphic-webcrypto": "^2.3.8",
"matrix-js-sdk": "^12.2.0",
+ "node-localstorage": "^2.2.1",
"olm": "https://packages.matrix.org/npm/olm/olm-3.1.4.tgz",
"utf8": "^3.0.0"
- },
- "devDependencies": {
- "node-localstorage": "^2.2.1"
}
},
"node_modules/@babel/code-frame": {
@@ -2337,7 +2336,6 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
"integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==",
- "optional": true,
"engines": {
"node": ">= 4.0.0"
}
@@ -4126,7 +4124,6 @@
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
- "optional": true,
"dependencies": {
"at-least-node": "^1.0.0",
"graceful-fs": "^4.2.0",
@@ -4298,8 +4295,7 @@
"node_modules/graceful-fs": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz",
- "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==",
- "devOptional": true
+ "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg=="
},
"node_modules/har-schema": {
"version": "2.0.0",
@@ -4537,7 +4533,6 @@
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
- "dev": true,
"engines": {
"node": ">=0.8.19"
}
@@ -5129,7 +5124,6 @@
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
- "optional": true,
"dependencies": {
"universalify": "^2.0.0"
},
@@ -6082,7 +6076,6 @@
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/node-localstorage/-/node-localstorage-2.2.1.tgz",
"integrity": "sha512-vv8fJuOUCCvSPjDjBLlMqYMHob4aGjkmrkaE42/mZr0VT+ZAU10jRF8oTnX9+pgU9/vYJ8P7YT3Vd6ajkmzSCw==",
- "dev": true,
"dependencies": {
"write-file-atomic": "^1.1.4"
},
@@ -7979,7 +7972,6 @@
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz",
"integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=",
- "dev": true,
"engines": {
"node": "*"
}
@@ -8822,7 +8814,6 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
"integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
- "optional": true,
"engines": {
"node": ">= 10.0.0"
}
@@ -9090,7 +9081,6 @@
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz",
"integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=",
- "dev": true,
"dependencies": {
"graceful-fs": "^4.1.11",
"imurmurhash": "^0.1.4",
@@ -11090,8 +11080,7 @@
"at-least-node": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
- "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==",
- "optional": true
+ "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg=="
},
"atob": {
"version": "2.1.2",
@@ -12552,7 +12541,6 @@
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
"integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
- "optional": true,
"requires": {
"at-least-node": "^1.0.0",
"graceful-fs": "^4.2.0",
@@ -12678,8 +12666,7 @@
"graceful-fs": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz",
- "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==",
- "devOptional": true
+ "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg=="
},
"har-schema": {
"version": "2.0.0",
@@ -12863,8 +12850,7 @@
"imurmurhash": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
- "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
- "dev": true
+ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o="
},
"inflight": {
"version": "1.0.6",
@@ -13357,7 +13343,6 @@
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
- "optional": true,
"requires": {
"graceful-fs": "^4.1.6",
"universalify": "^2.0.0"
@@ -14184,7 +14169,6 @@
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/node-localstorage/-/node-localstorage-2.2.1.tgz",
"integrity": "sha512-vv8fJuOUCCvSPjDjBLlMqYMHob4aGjkmrkaE42/mZr0VT+ZAU10jRF8oTnX9+pgU9/vYJ8P7YT3Vd6ajkmzSCw==",
- "dev": true,
"requires": {
"write-file-atomic": "^1.1.4"
}
@@ -15684,8 +15668,7 @@
"slide": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz",
- "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=",
- "dev": true
+ "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc="
},
"snapdragon": {
"version": "0.8.2",
@@ -16387,8 +16370,7 @@
"universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
- "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==",
- "optional": true
+ "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ=="
},
"unpipe": {
"version": "1.0.0",
@@ -16615,7 +16597,6 @@
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz",
"integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=",
- "dev": true,
"requires": {
"graceful-fs": "^4.1.11",
"imurmurhash": "^0.1.4",
diff --git a/package.json b/package.json
index 9fb74ad..a60ce84 100644
--- a/package.json
+++ b/package.json
@@ -1,14 +1,15 @@
{
"name": "node-red-contrib-matrix-chat",
- "version": "0.1.8",
+ "version": "0.2.0",
"description": "Matrix chat server client for Node-RED",
"dependencies": {
+ "fs-extra": "^9.1.0",
"got": "^11.8.2",
"isomorphic-webcrypto": "^2.3.8",
"matrix-js-sdk": "^12.2.0",
+ "node-localstorage": "^2.2.1",
"olm": "https://packages.matrix.org/npm/olm/olm-3.1.4.tgz",
- "utf8": "^3.0.0",
- "node-localstorage": "^2.2.1"
+ "utf8": "^3.0.0"
},
"node-red": {
"nodes": {
diff --git a/src/matrix-create-room.html b/src/matrix-create-room.html
index 6adb022..972827f 100644
--- a/src/matrix-create-room.html
+++ b/src/matrix-create-room.html
@@ -27,30 +27,19 @@
-
-
- User must be an admin to use this endpoint.
-
@@ -66,18 +40,18 @@
Inputs
msg.payload
- String
+ string
Usually an emoji but can also be text.
msg.topic
- String | Null
+ string | null
Room ID to send image to. Optional if configured on the node. If configured on the node this will be ignored.
Room ID to send file to. Optional if configured on the node. Overrides node configuration if set.
+
Room ID to send file to. Ignored if configured on the node, otherwise required.
msg.filename
- String | Null
+ string | null
-
name of the file to upload (optional). Overrides node configuration.
-
-
msg.contentType
- String | Null
-
-
Content MIME Type. Optional if configured on the node. Overrides node configuration if set.
+
name of the file to upload (optional). Note: If this is not defined the file will receive a randomly generated name (without an extension).
msg.body
- String | Null
+ string | null
-
this will be the display name the client will see when rendered in their chat client. If this is left empty the it uses msg.filename. If msg.filename is also undefined it sets it to empty string
+
this will be the display name the client will see when rendered in their chat client. If this is left empty it will just display as "Attachment".
+
+
msg.contentType
+ string | null
+
+
Content MIME Type. Optional but highly recommended (so the client receiving knows what type of file it is).
+
+
msg.content
+ object | null
+
+
craft your own msg.content to send to the server. If defined then msg.filename, msg.contentType, msg.body, and msg.payload aren't required since the file already exists.
Outputs
Success
-
original msg object preserved.
+
msg.eventId string
+
the eventId from the posted message.
Error
diff --git a/src/matrix-send-file.js b/src/matrix-send-file.js
index 247fb98..d6a6d59 100644
--- a/src/matrix-send-file.js
+++ b/src/matrix-send-file.js
@@ -61,17 +61,12 @@ module.exports = function(RED) {
return;
}
- msg.contentType = msg.contentType || node.contentType;
- if(!msg.contentType) {
- node.error('msg.contentType is required');
- return;
- }
-
+ msg.contentType = node.contentType || msg.contentType || null;
node.log("Uploading file " + msg.filename);
node.server.matrixClient.uploadContent(
msg.payload, {
name: msg.filename || null, // Name to give the file on the server.
- rawResponse: (msg.rawResponse || false), // Return the raw body, rather than parsing the JSON.
+ rawResponse: false, // Return the raw body, rather than parsing the JSON.
type: msg.contentType, // Content-type for the upload. Defaults to file.type, or applicaton/octet-stream.
onlyContentUri: false // Just return the content URI, rather than the whole body. Defaults to false. Ignored if opts.rawResponse is true.
})
@@ -79,18 +74,18 @@ module.exports = function(RED) {
const content = {
msgtype: 'm.file',
url: file.content_uri,
- body: (msg.body || msg.filename) || "",
+ body: msg.body || "",
};
node.server.matrixClient
.sendMessage(msg.topic, content)
- .then(function(imgResp) {
- node.log("File message sent: " + imgResp);
+ .then(function(e) {
+ node.log("File message sent: " + e);
msg.eventId = e.eventId;
node.send([msg, null]);
})
.catch(function(e){
node.warn("Error sending file message " + e);
- msg.matrixError = e;
+ msg.error = e;
node.send([null, msg]);
});
}).catch(function(e){
diff --git a/src/matrix-send-image.html b/src/matrix-send-image.html
index 2faa577..655c283 100644
--- a/src/matrix-send-image.html
+++ b/src/matrix-send-image.html
@@ -30,50 +30,50 @@
-
+
- Must be a valid MIME Type
+ Must be a valid MIME Type (ex: image/png) or left empty
Is optional but used for pagination, denoting the offset in the returned results. This should be treated as an opaque value and not explicitly set to anything other than the return value of next_token from a previous call. Defaults to 0.
+
Is optional but used for pagination, denoting the offset in the returned results. This should be treated as an opaque value and not explicitly set to anything other than the return value of msg.next_token from a previous call. Defaults to 0.
msg.limit
- Integer
+ integer
limit - representing a positive integer - Is optional but is used for pagination, denoting the maximum number of items to return in this call. Defaults to 100.
msg.guests
- Bool
+ bool
Is optional and if false will exclude guest users. Defaults to true to include guest users.
msg.order_by
- String
+ string
The method by which to sort the returned list of users.
@@ -85,14 +85,41 @@
msg.payload object
the response object from the server.
+
msg.payload.next_token string
+
string representing a positive integer - Indication for pagination. If this is unset then there are no more users to paginate through.
+
+
msg.payload.total integer
+
Total number of users.
+
msg.payload.users array
-
list of users from the Matrix server. Click here for details on what this contains (or do a test and dump the output). We would put the details here in the doc but Synapse is constantly changing so it's best to reference the official Synapse docs.
+
list of users from the Matrix server. Click here for details on what this contains (or do a debug on the output).
-
msg.next_token string
-
string representing a positive integer - Indication for pagination. See above (input msg.from)
+
msg.payload.users[].name string
+
Fully-qualified user ID (ex. @user:server.com).
-
msg.total integer
-
Total number of media.
+
msg.payload.users[].is_guest bool
+
Status if that user is a guest account.
+
+
msg.payload.users[].admin string
+
Status if that user is a server administrator.
+
+
msg.payload.users[].user_type string
+
Type of the user. Normal users are type None. This allows user type specific behaviour. There are also types support and bot.
+
+
msg.payload.users[].deactivated bool
+
Status if that user has been marked as deactivated.
+
+
msg.payload.users[].shadow_banned bool
+
Status if that user has been marked as shadow banned.
+
+
msg.payload.users[].displayname string
+
The user's display name if they have set one.
+
+
msg.payload.users[].avatar_url string
+
The user's avatar URL if they have set one.
+
+
msg.payload.users[].creation_ts integer
+
The user's creation timestamp in ms.
Error
diff --git a/src/matrix-synapse-users.js b/src/matrix-synapse-users.js
index 32d42e0..7be6eb3 100644
--- a/src/matrix-synapse-users.js
+++ b/src/matrix-synapse-users.js
@@ -58,7 +58,7 @@ module.exports = function(RED) {
msg.payload = e;
node.send([msg, null]);
}).catch(function(e){
- node.warn("Error fetching user list " + e);
+ node.warn("Error fetching server user list " + e);
msg.error = e;
node.send([null, msg]);
});
diff --git a/src/matrix-whois-user.html b/src/matrix-whois-user.html
index edf68a4..81f1386 100644
--- a/src/matrix-whois-user.html
+++ b/src/matrix-whois-user.html
@@ -36,6 +36,7 @@