diff --git a/ts/sql/Server.ts b/ts/sql/Server.ts index 4f106a9b598..e422794e602 100644 --- a/ts/sql/Server.ts +++ b/ts/sql/Server.ts @@ -5728,7 +5728,10 @@ async function removeAllConfiguration( } db.exec( - "UPDATE conversations SET json = json_remove(json, '$.senderKeyInfo');" + ` + UPDATE conversations SET json = json_remove(json, '$.senderKeyInfo'); + UPDATE storyDistributions SET senderKeyInfoJson = NULL; + ` ); })(); } diff --git a/ts/util/handleRetry.ts b/ts/util/handleRetry.ts index 7b278727740..d77825a0b0f 100644 --- a/ts/util/handleRetry.ts +++ b/ts/util/handleRetry.ts @@ -46,9 +46,10 @@ const RETRY_LIMIT = 5; // Entrypoints -const retryRecord = new Map(); +type RetryKeyType = `${AciString}.${number}:${number}`; +const retryRecord = new Map(); -export function _getRetryRecord(): Map { +export function _getRetryRecord(): Map { return retryRecord; } @@ -73,8 +74,9 @@ export async function onRetryRequest(event: RetryRequestEvent): Promise { return; } - const retryCount = (retryRecord.get(sentAt) || 0) + 1; - retryRecord.set(sentAt, retryCount); + const retryKey: RetryKeyType = `${requesterAci}.${requesterDevice}:${sentAt}`; + const retryCount = (retryRecord.get(retryKey) || 0) + 1; + retryRecord.set(retryKey, retryCount); if (retryCount > RETRY_LIMIT) { log.warn( `onRetryRequest/${logId}: retryCount is ${retryCount}; returning early.` @@ -232,8 +234,9 @@ export async function onDecryptionError( log.info(`onDecryptionError/${logId}: Starting...`); - const retryCount = (retryRecord.get(timestamp) || 0) + 1; - retryRecord.set(timestamp, retryCount); + const retryKey: RetryKeyType = `${senderAci}.${senderDevice}:${timestamp}`; + const retryCount = (retryRecord.get(retryKey) || 0) + 1; + retryRecord.set(retryKey, retryCount); if (retryCount > RETRY_LIMIT) { log.warn( `onDecryptionError/${logId}: retryCount is ${retryCount}; returning early.`