- Add back in persistent storage

- Receive node now accepts video files
This commit is contained in:
Skylar Sadlier 2022-12-06 21:49:05 -07:00
parent c7f9d56df2
commit 2fdc7482ce
3 changed files with 33 additions and 1 deletions

View File

@ -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"

View File

@ -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;

View File

@ -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