fix(e2ee): Subscription's `lastMessage` not properly decrypting (#38283)

pull/37614/merge
gabriellsh 1 week ago committed by GitHub
parent 1c474580b7
commit 54bd554166
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/cold-coats-cross.md
  2. 22
      apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
  3. 17
      apps/meteor/client/lib/e2ee/rocketchat.e2e.ts

@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---
Fixes an issue with encrypted room's message previews on the sidebar not always being properly decrypted

@ -666,18 +666,26 @@ export class E2ERoom extends Emitter {
return message;
}
// TODO(@cardoso): review backward compatibility
if (message.msg && !isEncryptedMessageContent(message)) {
const data = await this.decrypt(message.msg);
if (data.msg) {
message.msg = data.msg;
}
if (isEncryptedMessageContent(message)) {
return {
...(await this.decryptContent({ ...message })),
e2e: 'done' as const,
};
}
message = isEncryptedMessageContent(message) ? await this.decryptContent(message) : message;
if (!message.msg) {
return {
...message,
e2e: 'done' as const,
};
}
// TODO(@cardoso): review backward compatibility
const data = await this.decrypt(message.msg);
return {
...message,
msg: typeof data.msg === 'string' ? data.msg : message.msg,
e2e: 'done' as const,
};
}

@ -671,7 +671,22 @@ class E2E extends Emitter {
const span = log.span('decryptSubscription');
const e2eRoom = await this.getInstanceByRoomId(subscription.rid);
span.info(subscription._id);
await e2eRoom?.decryptSubscription();
if (!e2eRoom) {
span.warn('no e2eRoom found');
return;
}
if (e2eRoom.isReady()) {
span.info('e2e room ready');
await e2eRoom.decryptSubscription();
return;
}
e2eRoom.once('READY', async () => {
span.info('e2e room ready');
await e2eRoom.decryptSubscription();
});
}
async decryptSubscriptions(): Promise<void> {

Loading…
Cancel
Save