From a2962341635ce9ccd0965eec0ef9f797ea01bcce Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 26 Feb 2020 20:35:34 +0100 Subject: [PATCH] Fix crash after rework. RoomKeyShare is now an interface --- .../internal/crypto/IncomingRoomKeyRequestManager.kt | 6 ++---- .../internal/crypto/model/rest/RoomKeyShareCancellation.kt | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestManager.kt index 8bad39bd25..92a117d64b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingRoomKeyRequestManager.kt @@ -19,7 +19,6 @@ package im.vector.matrix.android.internal.crypto import im.vector.matrix.android.api.auth.data.Credentials import im.vector.matrix.android.api.session.crypto.keyshare.RoomKeysRequestListener import im.vector.matrix.android.api.session.events.model.Event -import im.vector.matrix.android.api.session.events.model.toModel import im.vector.matrix.android.internal.crypto.model.rest.RoomKeyShare import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore import im.vector.matrix.android.internal.session.SessionScope @@ -51,11 +50,10 @@ internal class IncomingRoomKeyRequestManager @Inject constructor( * @param event the announcement event. */ fun onRoomKeyRequestEvent(event: Event) { - val roomKeyShare = event.getClearContent().toModel() - when (roomKeyShare?.action) { + when (val roomKeyShareAction = event.getClearContent()?.get("action") as? String) { RoomKeyShare.ACTION_SHARE_REQUEST -> IncomingRoomKeyRequest.fromEvent(event)?.let { receivedRoomKeyRequests.add(it) } RoomKeyShare.ACTION_SHARE_CANCELLATION -> IncomingRoomKeyRequestCancellation.fromEvent(event)?.let { receivedRoomKeyRequestCancellations.add(it) } - else -> Timber.e("## onRoomKeyRequestEvent() : unsupported action ${roomKeyShare?.action}") + else -> Timber.e("## onRoomKeyRequestEvent() : unsupported action $roomKeyShareAction") } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareCancellation.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareCancellation.kt index 110eed04c1..b394993338 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareCancellation.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/RoomKeyShareCancellation.kt @@ -17,7 +17,6 @@ package im.vector.matrix.android.internal.crypto.model.rest import com.squareup.moshi.Json import com.squareup.moshi.JsonClass -import im.vector.matrix.android.internal.crypto.model.rest.RoomKeyShare.Companion.ACTION_SHARE_CANCELLATION /** * Class representing a room key request cancellation content @@ -25,7 +24,7 @@ import im.vector.matrix.android.internal.crypto.model.rest.RoomKeyShare.Companio @JsonClass(generateAdapter = true) internal data class RoomKeyShareCancellation( @Json(name = "action") - override val action: String? = ACTION_SHARE_CANCELLATION, + override val action: String? = RoomKeyShare.ACTION_SHARE_CANCELLATION, @Json(name = "requesting_device_id") override val requestingDeviceId: String? = null,