From ad06b947086d45dd612ca12677c9da5255abd705 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 10 Feb 2021 18:08:31 +1100 Subject: [PATCH] do not drop a message which was not decrypted for a medium group Instead, trigger a request to the group to get the encryption keypair. We will try to process those messages on an app restart --- ts/receiver/cache.ts | 2 +- ts/receiver/contentMessage.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ts/receiver/cache.ts b/ts/receiver/cache.ts index d4ecb174f..45264d404 100644 --- a/ts/receiver/cache.ts +++ b/ts/receiver/cache.ts @@ -54,7 +54,7 @@ export async function getAllFromCache() { const attempts = _.toNumber(item.attempts || 0) + 1; try { - if (attempts >= 3) { + if (attempts >= 10) { window.log.warn( 'getAllFromCache final attempt for envelope', item.id diff --git a/ts/receiver/contentMessage.ts b/ts/receiver/contentMessage.ts index 7735ff130..1b87af67d 100644 --- a/ts/receiver/contentMessage.ts +++ b/ts/receiver/contentMessage.ts @@ -127,7 +127,12 @@ async function decryptForClosedGroup( keypairRequestManager.markRequestSendFor(groupPubKey, Date.now()); await requestEncryptionKeyPair(groupPubKey); } - await removeFromCache(envelope); + throw new Error( + `Waiting for an encryption keypair to be received for group ${groupPubKey.key}` + ); + // do not remove it from the cache yet. We will try to decrypt it once we get the encryption keypair + // TODO drop it if after some time we still don't get to decrypt it + // await removeFromCache(envelope); return null; } }