From 14ab7b9e0dce3ed108697c63173d8afc876b32f7 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 14 Apr 2022 15:27:16 -0700 Subject: [PATCH] Fetch profiles for conversations needing verification, more logging too --- ts/state/ducks/conversations.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index a8e4cd86a2e3..c81119e85fef 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -2,6 +2,8 @@ // SPDX-License-Identifier: AGPL-3.0-only /* eslint-disable camelcase */ + +import PQueue from 'p-queue'; import type { ThunkAction } from 'redux-thunk'; import { difference, @@ -1272,6 +1274,10 @@ function verifyConversationsStoppingSend(): ThunkAction< const conversationIdsStoppingSend = getConversationIdsStoppingSend(state); const conversationIdsBlocked = getConversationIdsStoppedForVerification(state); + log.info( + `verifyConversationsStoppingSend: Starting with ${conversationIdsBlocked.length} blocked ` + + `conversations and ${conversationIdsStoppingSend.length} conversations to verify.` + ); // Mark conversations as approved/verified as appropriate const promises: Array> = []; @@ -1280,6 +1286,10 @@ function verifyConversationsStoppingSend(): ThunkAction< if (!conversation) { return; } + + log.info( + `verifyConversationsStoppingSend: Verifying conversation ${conversation.idForLogging()}` + ); if (conversation.isUnverified()) { promises.push(conversation.setVerifiedDefault()); } @@ -1495,6 +1505,27 @@ function conversationStoppedByMissingVerification(payload: { conversationId: string; untrustedConversationIds: ReadonlyArray; }): ConversationStoppedByMissingVerificationActionType { + // Fetching profiles to ensure that we have their latest identity key in storage + const profileFetchQueue = new PQueue({ + concurrency: 3, + }); + payload.untrustedConversationIds.forEach(untrustedConversationId => { + const conversation = window.ConversationController.get( + untrustedConversationId + ); + if (!conversation) { + log.error( + `conversationStoppedByMissingVerification: conversationId ${untrustedConversationId} not found!` + ); + return; + } + + profileFetchQueue.add(() => { + const active = conversation.getActiveProfileFetch(); + return active || conversation.getProfiles(); + }); + }); + return { type: CONVERSATION_STOPPED_BY_MISSING_VERIFICATION, payload,