From f1da77fb6bdd0c59277c935bc7b5543b0fd6e18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 11 Aug 2021 15:51:24 +0200 Subject: [PATCH] crypto: Avoid converting numbers in to-device requests to floats This mainly avoid converting the type field in m.olm.v1.curve25519-aes-sha2 variant of an m.room.encrypted event that gets sent out over to-device messages. --- .../android/sdk/internal/crypto/DefaultCryptoService.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt index 5c5e721100..eff19dda48 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt @@ -88,6 +88,7 @@ import org.matrix.android.sdk.internal.di.MoshiProvider import org.matrix.android.sdk.internal.di.SessionFilesDirectory import org.matrix.android.sdk.internal.di.UserId import org.matrix.android.sdk.internal.extensions.foldToCallback +import org.matrix.android.sdk.internal.network.parsing.CheckNumberType import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.session.room.membership.LoadRoomMembersTask import org.matrix.android.sdk.internal.session.sync.model.DeviceListResponse @@ -227,9 +228,11 @@ internal class RequestSender @Inject constructor( } suspend fun sendToDevice(eventType: String, body: String, transactionId: String) { - // TODO this produces floats for the Olm type fields, which are integers originally. val adapter = MoshiProvider .providesMoshi() + .newBuilder() + .add(CheckNumberType.JSON_ADAPTER_FACTORY) + .build() .adapter>>(Map::class.java) val jsonBody = adapter.fromJson(body)!!