mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2025-07-09 04:01:11 -06:00
Compare commits
4 Commits
3c042ae47d
...
ce8be4a30f
Author | SHA1 | Date | |
---|---|---|---|
ce8be4a30f | |||
3e808cabec | |||
2fdc7482ce | |||
c7f9d56df2 |
@ -26,9 +26,7 @@ The following is supported from this package:
|
|||||||
- Get a user list from a room
|
- Get a user list from a room
|
||||||
- Kick user from room
|
- Kick user from room
|
||||||
- Ban user from room
|
- Ban user from room
|
||||||
- Join a room
|
- Join, Create, Invite, and Leave rooms
|
||||||
- Create a room
|
|
||||||
- Invite to a room
|
|
||||||
- Synapse admin API to force add user to room (requires bot to be in same room already)
|
- Synapse admin API to force add user to room (requires bot to be in same room already)
|
||||||
|
|
||||||
|
|
||||||
|
30
package-lock.json
generated
30
package-lock.json
generated
@ -10,10 +10,10 @@
|
|||||||
"license": "SEE LICENSE FILE",
|
"license": "SEE LICENSE FILE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"abort-controller": "^3.0.0",
|
"abort-controller": "^3.0.0",
|
||||||
"fs-extra": "^10.0.1",
|
"fs-extra": "^11.1.0",
|
||||||
"got": "^12.0.2",
|
"got": "^12.0.2",
|
||||||
"isomorphic-webcrypto": "^2.3.8",
|
"isomorphic-webcrypto": "^2.3.8",
|
||||||
"matrix-js-sdk": "^21.2.0",
|
"matrix-js-sdk": "^22.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/472/download",
|
"olm": "https://gitlab.matrix.org/matrix-org/olm/-/package_files/472/download",
|
||||||
@ -7100,16 +7100,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fs-extra": {
|
"node_modules/fs-extra": {
|
||||||
"version": "10.1.0",
|
"version": "11.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.0.tgz",
|
||||||
"integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
|
"integrity": "sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"graceful-fs": "^4.2.0",
|
"graceful-fs": "^4.2.0",
|
||||||
"jsonfile": "^6.0.1",
|
"jsonfile": "^6.0.1",
|
||||||
"universalify": "^2.0.0"
|
"universalify": "^2.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=14.14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fs-minipass": {
|
"node_modules/fs-minipass": {
|
||||||
@ -8895,9 +8895,9 @@
|
|||||||
"integrity": "sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA=="
|
"integrity": "sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA=="
|
||||||
},
|
},
|
||||||
"node_modules/matrix-js-sdk": {
|
"node_modules/matrix-js-sdk": {
|
||||||
"version": "21.2.0",
|
"version": "22.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-21.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-22.0.0.tgz",
|
||||||
"integrity": "sha512-5aHWkWve+/5dmRJGIAzwe2hFNHX/2LBFWVqHh6YOTSViWlAbBxQsylBIhsNppgmHUN1YjBhvBlW206UnYCk6zg==",
|
"integrity": "sha512-mpKqeD3nCobjGiUiATUyEoP44n+AzDW5cSeBTIBY5fPhj0AkzLJhblHt40vzSOJazj8tT0PhsSzhEIR9hGzYGA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
"@types/sdp-transform": "^2.4.5",
|
"@types/sdp-transform": "^2.4.5",
|
||||||
@ -19554,9 +19554,9 @@
|
|||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
"fs-extra": {
|
"fs-extra": {
|
||||||
"version": "10.1.0",
|
"version": "11.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.0.tgz",
|
||||||
"integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
|
"integrity": "sha512-0rcTq621PD5jM/e0a3EJoGC/1TC5ZBCERW82LQuwfGnCa1V8w7dpYH1yNu+SLb6E5dkeCBzKEyLGlFrnr+dUyw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"graceful-fs": "^4.2.0",
|
"graceful-fs": "^4.2.0",
|
||||||
"jsonfile": "^6.0.1",
|
"jsonfile": "^6.0.1",
|
||||||
@ -20974,9 +20974,9 @@
|
|||||||
"integrity": "sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA=="
|
"integrity": "sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA=="
|
||||||
},
|
},
|
||||||
"matrix-js-sdk": {
|
"matrix-js-sdk": {
|
||||||
"version": "21.2.0",
|
"version": "22.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-21.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/matrix-js-sdk/-/matrix-js-sdk-22.0.0.tgz",
|
||||||
"integrity": "sha512-5aHWkWve+/5dmRJGIAzwe2hFNHX/2LBFWVqHh6YOTSViWlAbBxQsylBIhsNppgmHUN1YjBhvBlW206UnYCk6zg==",
|
"integrity": "sha512-mpKqeD3nCobjGiUiATUyEoP44n+AzDW5cSeBTIBY5fPhj0AkzLJhblHt40vzSOJazj8tT0PhsSzhEIR9hGzYGA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/runtime": "^7.12.5",
|
"@babel/runtime": "^7.12.5",
|
||||||
"@types/sdp-transform": "^2.4.5",
|
"@types/sdp-transform": "^2.4.5",
|
||||||
|
12
package.json
12
package.json
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-matrix-chat",
|
"name": "node-red-contrib-matrix-chat",
|
||||||
"version": "0.6.1",
|
"version": "0.7.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",
|
||||||
"fs-extra": "^10.0.1",
|
"fs-extra": "^11.1.0",
|
||||||
"got": "^12.0.2",
|
"got": "^12.0.2",
|
||||||
"isomorphic-webcrypto": "^2.3.8",
|
"isomorphic-webcrypto": "^2.3.8",
|
||||||
"matrix-js-sdk": "^21.2.0",
|
"matrix-js-sdk": "^22.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/472/download",
|
"olm": "https://gitlab.matrix.org/matrix-org/olm/-/package_files/472/download",
|
||||||
@ -47,9 +47,9 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"node-red",
|
"node-red",
|
||||||
"matrix",
|
"matrix",
|
||||||
"support",
|
"chat",
|
||||||
"bot",
|
"chatbot",
|
||||||
"chat"
|
"federated"
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
acceptFiles: {"value": true},
|
acceptFiles: {"value": true},
|
||||||
acceptAudio: {"value": true},
|
acceptAudio: {"value": true},
|
||||||
acceptImages: {"value": true},
|
acceptImages: {"value": true},
|
||||||
|
acceptVideos: {"value": true},
|
||||||
acceptLocations: {"value": true},
|
acceptLocations: {"value": true},
|
||||||
},
|
},
|
||||||
label: function() {
|
label: function() {
|
||||||
@ -114,6 +115,16 @@
|
|||||||
Accept images <code style="text-transform: none;">m.image</code>
|
Accept images <code style="text-transform: none;">m.image</code>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="node-input-acceptVideos"
|
||||||
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
||||||
|
/>
|
||||||
|
<label for="node-input-acceptVideos" style="width: auto">
|
||||||
|
Accept videos <code style="text-transform: none;">m.video</code>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
@ -13,6 +13,7 @@ module.exports = function(RED) {
|
|||||||
this.acceptFiles = n.acceptFiles;
|
this.acceptFiles = n.acceptFiles;
|
||||||
this.acceptAudio = n.acceptAudio;
|
this.acceptAudio = n.acceptAudio;
|
||||||
this.acceptImages = n.acceptImages;
|
this.acceptImages = n.acceptImages;
|
||||||
|
this.acceptVideos = n.acceptVideos;
|
||||||
this.acceptLocations = n.acceptLocations;
|
this.acceptLocations = n.acceptLocations;
|
||||||
this.roomId = n.roomId;
|
this.roomId = n.roomId;
|
||||||
this.roomIds = this.roomId ? this.roomId.split(',') : [];
|
this.roomIds = this.roomId ? this.roomId.split(',') : [];
|
||||||
@ -111,6 +112,23 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case 'm.video':
|
||||||
|
if(!node.acceptVideos) return;
|
||||||
|
msg.filename = msg.content.filename || msg.content.body;
|
||||||
|
if(msg.encrypted) {
|
||||||
|
msg.url = node.server.matrixClient.mxcUrlToHttp(msg.content.file.url);
|
||||||
|
msg.mxc_url = msg.content.file.url;
|
||||||
|
msg.thumbnail_url = node.server.matrixClient.mxcUrlToHttp(msg.content.info.thumbnail_file.url);
|
||||||
|
msg.thumbnail_mxc_url = msg.content.info.thumbnail_file.url;
|
||||||
|
} else {
|
||||||
|
msg.url = node.server.matrixClient.mxcUrlToHttp(msg.content.url);
|
||||||
|
msg.mxc_url = msg.content.url;
|
||||||
|
msg.thumbnail_url = node.server.matrixClient.mxcUrlToHttp(msg.content.info.thumbnail_url);
|
||||||
|
msg.thumbnail_mxc_url = msg.content.info.thumbnail_url;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'm.location':
|
case 'm.location':
|
||||||
if(!node.acceptLocations) return;
|
if(!node.acceptLocations) return;
|
||||||
msg.geo_uri = msg.content.geo_uri;
|
msg.geo_uri = msg.content.geo_uri;
|
||||||
|
@ -4,7 +4,7 @@ const sdk = require("matrix-js-sdk");
|
|||||||
const { resolve } = require('path');
|
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} = require("matrix-js-sdk");
|
const {RoomEvent, RoomMemberEvent, HttpApiEvent, ClientEvent, MemoryStore} = require("matrix-js-sdk");
|
||||||
const request = require("request");
|
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) {
|
||||||
@ -138,6 +138,9 @@ module.exports = function(RED) {
|
|||||||
baseUrl: this.url,
|
baseUrl: this.url,
|
||||||
accessToken: this.credentials.accessToken,
|
accessToken: this.credentials.accessToken,
|
||||||
cryptoStore: new LocalStorageCryptoStore(localStorage),
|
cryptoStore: new LocalStorageCryptoStore(localStorage),
|
||||||
|
store: new MemoryStore({
|
||||||
|
localStorage: localStorage,
|
||||||
|
}),
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
deviceId: (this.deviceId || getStoredDeviceId(localStorage)) || undefined,
|
deviceId: (this.deviceId || getStoredDeviceId(localStorage)) || undefined,
|
||||||
request
|
request
|
||||||
|
@ -52,7 +52,6 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
node.server.matrixClient.http
|
node.server.matrixClient.http
|
||||||
.authedRequest(
|
.authedRequest(
|
||||||
undefined,
|
|
||||||
'PUT',
|
'PUT',
|
||||||
node.encodeUri(
|
node.encodeUri(
|
||||||
"/_synapse/admin/v2/users/$userId",
|
"/_synapse/admin/v2/users/$userId",
|
||||||
|
@ -56,7 +56,6 @@ module.exports = function(RED) {
|
|||||||
);
|
);
|
||||||
node.server.matrixClient.http
|
node.server.matrixClient.http
|
||||||
.authedRequest(
|
.authedRequest(
|
||||||
undefined,
|
|
||||||
'POST',
|
'POST',
|
||||||
path,
|
path,
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -60,7 +60,6 @@ module.exports = function(RED) {
|
|||||||
// we need the status code, so set onlydata to false for this request
|
// we need the status code, so set onlydata to false for this request
|
||||||
node.server.matrixClient.http
|
node.server.matrixClient.http
|
||||||
.authedRequest(
|
.authedRequest(
|
||||||
undefined,
|
|
||||||
'POST',
|
'POST',
|
||||||
node.encodeUri(
|
node.encodeUri(
|
||||||
"/_synapse/admin/v1/join/$room_id_or_alias",
|
"/_synapse/admin/v1/join/$room_id_or_alias",
|
||||||
|
@ -48,7 +48,6 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
node.server.matrixClient.http
|
node.server.matrixClient.http
|
||||||
.authedRequest(
|
.authedRequest(
|
||||||
undefined,
|
|
||||||
'GET',
|
'GET',
|
||||||
"/_synapse/admin/v2/users",
|
"/_synapse/admin/v2/users",
|
||||||
queryParams,
|
queryParams,
|
||||||
|
@ -53,7 +53,6 @@ module.exports = function(RED) {
|
|||||||
// we need the status code, so set onlydata to false for this request
|
// we need the status code, so set onlydata to false for this request
|
||||||
node.server.matrixClient.http
|
node.server.matrixClient.http
|
||||||
.authedRequest(
|
.authedRequest(
|
||||||
undefined,
|
|
||||||
'GET',
|
'GET',
|
||||||
node.encodeUri(
|
node.encodeUri(
|
||||||
"/_matrix/client/r0/admin/whois/$userId",
|
"/_matrix/client/r0/admin/whois/$userId",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user