mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2025-04-20 04:53:06 -06:00
- Fixed not being able to disable e2ee
- Session.logged_out events are now processed to display an error from the node (helps user figure out why their login failed).
This commit is contained in:
parent
3eab7f6d98
commit
b93a54f041
@ -6,12 +6,12 @@
|
|||||||
userId: { type: "text", required: true },
|
userId: { type: "text", required: true },
|
||||||
accessToken: { type: "password", required: true },
|
accessToken: { type: "password", required: true },
|
||||||
deviceId: { type: "text", required: true },
|
deviceId: { type: "text", required: true },
|
||||||
url: { type: "text", required: true },
|
url: { type: "text", required: true }
|
||||||
enableE2ee: { type: "checkbox", value: true }
|
|
||||||
},
|
},
|
||||||
defaults: {
|
defaults: {
|
||||||
name: { value: null },
|
name: { value: null },
|
||||||
autoAcceptRoomInvites: { value: true }
|
autoAcceptRoomInvites: { value: true },
|
||||||
|
enableE2ee: { type: "checkbox", value: true }
|
||||||
},
|
},
|
||||||
icon: "matrix.png",
|
icon: "matrix.png",
|
||||||
label: function() {
|
label: function() {
|
||||||
|
@ -27,7 +27,7 @@ module.exports = function(RED) {
|
|||||||
this.deviceId = this.credentials.deviceId || null;
|
this.deviceId = this.credentials.deviceId || null;
|
||||||
this.url = this.credentials.url;
|
this.url = this.credentials.url;
|
||||||
this.autoAcceptRoomInvites = n.autoAcceptRoomInvites;
|
this.autoAcceptRoomInvites = n.autoAcceptRoomInvites;
|
||||||
this.enableE2ee = this.credentials.enableE2ee || false;
|
this.enableE2ee = this.enableE2ee || false;
|
||||||
this.e2ee = this.enableE2ee && this.deviceId;
|
this.e2ee = this.enableE2ee && this.deviceId;
|
||||||
|
|
||||||
if(!this.credentials.accessToken) {
|
if(!this.credentials.accessToken) {
|
||||||
@ -134,15 +134,38 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
node.matrixClient.on("Session.logged_out", async function(errorObj){
|
||||||
|
// Example if user auth token incorrect:
|
||||||
|
// {
|
||||||
|
// errcode: 'M_UNKNOWN_TOKEN',
|
||||||
|
// data: {
|
||||||
|
// errcode: 'M_UNKNOWN_TOKEN',
|
||||||
|
// error: 'Invalid macaroon passed.',
|
||||||
|
// soft_logout: false
|
||||||
|
// },
|
||||||
|
// httpStatus: 401
|
||||||
|
// }
|
||||||
|
|
||||||
|
node.error("[Session.logged_out] " + errorObj);
|
||||||
|
});
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
if(node.e2ee){
|
if(node.e2ee){
|
||||||
node.matrixClient.initCrypto()
|
const initCrypto = ms => new Promise(res => node.matrixClient.initCrypto());
|
||||||
.catch((error) => node.error(error));
|
try {
|
||||||
|
await initCrypto();
|
||||||
|
} catch(error){
|
||||||
|
node.error(error);
|
||||||
|
}
|
||||||
node.matrixClient.setGlobalErrorOnUnknownDevices(false);
|
node.matrixClient.setGlobalErrorOnUnknownDevices(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
node.matrixClient.startClient({ initialSyncLimit: 8 })
|
const startClient = ms => new Promise(res => node.matrixClient.startClient({ initialSyncLimit: 8 }));
|
||||||
.catch((error) => node.error(error));
|
try {
|
||||||
|
await startClient();
|
||||||
|
} catch(error){
|
||||||
|
node.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node.log("Connecting to Matrix server...");
|
node.log("Connecting to Matrix server...");
|
||||||
@ -155,7 +178,6 @@ module.exports = function(RED) {
|
|||||||
userId: { type:"text", required: true },
|
userId: { type:"text", required: true },
|
||||||
accessToken: { type:"text", required: true },
|
accessToken: { type:"text", required: true },
|
||||||
deviceId: { type: "text", required: true },
|
deviceId: { type: "text", required: true },
|
||||||
enableE2ee: { type: "checkbox", value: true },
|
|
||||||
url: { type: "text", required: true },
|
url: { type: "text", required: true },
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user