Regression: Messages not being encrypted E2E (#20922)

pull/20931/head
Guilherme Gazzo 4 years ago committed by GitHub
parent 8a5c5f3971
commit 472b67cc5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      app/e2e/client/rocketchat.e2e.js
  2. 6
      app/e2e/client/rocketchat.e2e.room.js

@ -9,7 +9,6 @@ import { Emitter } from '@rocket.chat/emitter';
import { E2ERoom } from './rocketchat.e2e.room';
import {
Deferred,
toString,
toArrayBuffer,
joinVectorAndEcryptedData,
@ -22,15 +21,17 @@ import {
importRawKey,
deriveKey,
} from './helper';
import * as banners from '../../../client/lib/banners';
import { Rooms, Subscriptions, Messages } from '../../models';
import { promises } from '../../promises/client';
import { settings } from '../../settings';
import { Notifications } from '../../notifications/client';
import { Layout, call, modal } from '../../ui-utils';
import * as banners from '../../../client/lib/banners';
import './events.js';
import './tabbar';
import { getConfig } from '../../ui-utils/client/config';
const debug = [getConfig('debug'), getConfig('debug-e2e')].includes('true');
let failedToDecodeKey = false;
@ -47,23 +48,23 @@ class E2E extends Emitter {
this.enabled = new ReactiveVar(false);
this._ready = new ReactiveVar(false);
this.instancesByRoomId = {};
this.readyPromise = new Deferred();
this.on('ready', () => {
this._ready.set(true);
this.log('startClient -> Done');
this.log('decryptPendingSubscriptions');
this.decryptPendingSubscriptions();
this.log('decryptPendingSubscriptions -> Done');
this.log('decryptSubscriptions');
this.decryptSubscriptions();
this.log('decryptSubscriptions -> Done');
});
}
log(...msg) {
console.log('[E2E]', ...msg);
debug && console.log('[E2E]', ...msg);
}
error(...msg) {
console.error('[E2E]', ...msg);
debug && console.error('[E2E]', ...msg);
}
@ -75,10 +76,6 @@ class E2E extends Emitter {
return this.enabled.get() && this._ready.get();
}
async ready() {
return this.readyPromise;
}
getE2ERoom(rid) {
return this.instancesByRoomId[rid];
}
@ -88,8 +85,6 @@ class E2E extends Emitter {
}
async getInstanceByRoomId(roomId) {
await this.ready();
const room = await waitUntilFind(() => Rooms.findOne({
_id: roomId,
}));
@ -191,12 +186,6 @@ class E2E extends Emitter {
},
});
}
this.log('startClient -> Done');
this.log('decryptSubscriptions');
this.decryptSubscriptions();
this.log('decryptSubscriptions -> Done');
this.emit('ready');
}
@ -415,7 +404,7 @@ class E2E extends Emitter {
async decryptSubscription(rid) {
const e2eRoom = await this.getInstanceByRoomId(rid);
this.log('decryptSubscription ->', rid);
e2eRoom?.decryptPendingSubscription();
e2eRoom?.decryptSubscription();
}
async decryptSubscriptions() {
@ -498,7 +487,7 @@ Meteor.startup(function() {
if (!e2eRoom.isReady()) {
return;
}
e2eRoom.decryptPendingSubscription();
e2eRoom.decryptSubscription();
},
added: async (doc) => {
if (!doc.encrypted && !doc.E2EKey) {

@ -26,6 +26,7 @@ import { Notifications } from '../../notifications/client';
import { Rooms, Subscriptions, Messages } from '../../models';
import { call } from '../../ui-utils';
import { roomTypes, RoomSettingsEnum } from '../../utils';
import { getConfig } from '../../ui-utils/client/config';
export const E2E_ROOM_STATES = {
NO_PASSWORD_SET: 'NO_PASSWORD_SET',
@ -64,15 +65,16 @@ const reduce = (prev, next) => {
}
};
const debug = [getConfig('debug'), getConfig('debug-e2e')].includes('true');
export class E2ERoom extends Emitter {
log(...msg) {
if (this.roomId === Session.get('openedRoom')) {
if (debug) {
console.log('[E2E ROOM]', `[STATE: ${ this.state }]`, `[RID: ${ this.roomId }]`, ...msg);
}
}
error(...msg) {
if (this.roomId === Session.get('openedRoom')) {
if (debug) {
console.error('[E2E ROOM]', `[STATE: ${ this.state }]`, `[RID: ${ this.roomId }]`, ...msg);
}
}

Loading…
Cancel
Save