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.
This commit is contained in:
Damir Jelić 2021-08-11 15:51:24 +02:00
parent 00d1233512
commit f1da77fb6b
1 changed files with 4 additions and 1 deletions

View File

@ -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<String, HashMap<String, Any>>>(Map::class.java)
val jsonBody = adapter.fromJson(body)!!