From 49d33f3a4b955b685aacce8b6cbdeb14d25d7592 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 1 Mar 2022 17:26:52 +0100 Subject: [PATCH] avoid duplicate userId on key download --- .../org/matrix/android/sdk/internal/crypto/EventDecryptor.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/EventDecryptor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/EventDecryptor.kt index d10019e1d3..f053168bd7 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/EventDecryptor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/EventDecryptor.kt @@ -172,13 +172,14 @@ internal class EventDecryptor @Inject constructor( toUnwedge .chunked(100) // safer to chunk if we ever have lots of wedged devices .forEach { wedgedList -> + val groupedByUserId = wedgedList.groupBy { it.userId } // lets download keys if needed withContext(coroutineDispatchers.io) { - deviceListManager.downloadKeys(wedgedList.map { it.userId }, false) + deviceListManager.downloadKeys(groupedByUserId.keys.toList(), false) } // find the matching devices - wedgedList.groupBy { it.userId } + groupedByUserId .map { groupedByUser -> val userId = groupedByUser.key val wedgeSenderKeysForUser = groupedByUser.value.map { it.senderKey }