From 4ead39038c06ca1ed120e7bcf8da57f8e8d9e1f5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 21 Jul 2021 14:06:47 +0200 Subject: [PATCH] Code review --- .../android/sdk/internal/crypto/tasks/SendToDeviceTask.kt | 4 +++- .../android/sdk/internal/crypto/util/RequestIdHelper.kt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt index 4b60d54238..c6af9b0cd1 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/tasks/SendToDeviceTask.kt @@ -46,7 +46,9 @@ internal class DefaultSendToDeviceTask @Inject constructor( messages = params.contentMap.map ) - // Create a unique txnId first, to use the same value if the request is retried + // If params.transactionId is not provided, we create a unique txnId. + // It's important to do that outside the requestBlock parameter of executeRequest() + // to use the same value if the request is retried val txnId = params.transactionId ?: createUniqueTxnId() return executeRequest( diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/util/RequestIdHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/util/RequestIdHelper.kt index 9b3cb1942a..3106d5820c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/util/RequestIdHelper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/util/RequestIdHelper.kt @@ -19,5 +19,5 @@ package org.matrix.android.sdk.internal.crypto.util import java.util.UUID internal object RequestIdHelper { - fun createUniqueRequestId() = "req_" + UUID.randomUUID().toString() + fun createUniqueRequestId() = UUID.randomUUID().toString() }