diff --git a/client/src/builtin/E2EE.js b/client/src/builtin/E2EE.js index a3d89ce5..bea02c10 100644 --- a/client/src/builtin/E2EE.js +++ b/client/src/builtin/E2EE.js @@ -31,7 +31,6 @@ export default new class E2EE extends BuiltinModule { constructor() { super(); - window.nodecrypto = nodecrypto; this.encryptNewMessages = true; this.ecdhDate = START_DATE; } @@ -147,6 +146,8 @@ export default new class E2EE extends BuiltinModule { const secret = this.computeSecret(channelId, key); this.setKey(channelId, secret); Toasts.success('Key exchange complete!'); + if (this.preEchangeState) this.encryptNewMessages = this.preEchangeState; + this.preEchangeState = null; } catch (err) { return; } diff --git a/client/src/builtin/E2EEComponent.vue b/client/src/builtin/E2EEComponent.vue index af5d1636..50b6cfe2 100644 --- a/client/src/builtin/E2EEComponent.vue +++ b/client/src/builtin/E2EEComponent.vue @@ -92,6 +92,7 @@ Toasts.warning('Key exchange for channel already in progress!'); return; } + E2EE.preEchangeState = E2EE.encryptNewMessages; E2EE.encryptNewMessages = false; // Disable encrypting new messages so we won't encrypt public keys const publicKeyMessage = `\`\`\`\n-----BEGIN PUBLIC KEY-----\n${keyExchange}\n-----END PUBLIC KEY-----\n\`\`\``; WebpackModules.getModuleByName('DraftActions').saveDraft(DiscordApi.currentChannel.id, publicKeyMessage);