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() }