From 935b3d7f3f9126951a25934b88ed57984189cb19 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 30 Dec 2019 20:18:08 +0100 Subject: [PATCH] cleaning --- .../api/session/crypto/sas/SasVerificationTransaction.kt | 1 - .../internal/crypto/model/rest/KeyVerificationReady.kt | 2 +- .../crypto/verification/DefaultSasVerificationService.kt | 6 ++---- .../android/internal/crypto/verification/SasTransport.kt | 1 - .../features/crypto/verification/VerificationBottomSheet.kt | 2 +- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/SasVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/SasVerificationTransaction.kt index b98c5c0167..af47b54a00 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/SasVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/SasVerificationTransaction.kt @@ -48,6 +48,5 @@ interface SasVerificationTransaction { */ fun userHasVerifiedShortCode() - fun shortCodeDoNotMatch() } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationReady.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationReady.kt index 7df12b22c6..ca3b1e0075 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationReady.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/KeyVerificationReady.kt @@ -25,7 +25,7 @@ import im.vector.matrix.android.internal.crypto.verification.VerificationInfoRea @JsonClass(generateAdapter = true) internal data class KeyVerificationReady( @Json(name = "from_device") override val fromDevice: String?, - //TODO add qr? + // TODO add qr? @Json(name = "methods") override val methods: List? = listOf(KeyVerificationStart.VERIF_METHOD_SAS), @Json(name = "transaction_id") override var transactionID: String? = null ) : SendToDeviceObject, VerificationInfoReady { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt index 64f1b4b308..a5ac169729 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultSasVerificationService.kt @@ -80,7 +80,6 @@ internal class DefaultSasVerificationService @Inject constructor( */ private val pendingRequests = HashMap>() - // Event received from the sync fun onToDeviceEvent(event: Event) { GlobalScope.launch(coroutineDispatchers.crypto) { @@ -184,7 +183,6 @@ internal class DefaultSasVerificationService @Inject constructor( } } - private fun dispatchRequestAdded(tx: PendingVerificationRequest) { uiHandler.post { listeners.forEach { @@ -756,14 +754,14 @@ internal class DefaultSasVerificationService @Inject constructor( override fun readyPendingVerificationInDMs(otherUserId: String, roomId: String, transactionId: String) { // Let's find the related request getExistingVerificationRequest(otherUserId)?.find { it.transactionId == transactionId }?.let { - //we need to send a ready event, with matching methods + // we need to send a ready event, with matching methods val transport = sasTransportRoomMessageFactory.createTransport(roomId, cryptoService, null) val methods = it.requestInfo?.methods?.intersect(listOf(KeyVerificationStart.VERIF_METHOD_SAS))?.toList() if (methods.isNullOrEmpty()) { Timber.i("Cannot ready this request, no common methods found txId:$transactionId") return@let } - //TODO this is not yet related to a transaction, maybe we should use another method like for cancel? + // TODO this is not yet related to a transaction, maybe we should use another method like for cancel? val readyMsg = transport.createReady(transactionId, credentials.deviceId ?: "", methods) transport.sendToOther(EventType.KEY_VERIFICATION_READY, readyMsg, SasVerificationTxState.None, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SasTransport.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SasTransport.kt index 1befc74525..b4d5a9ee76 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SasTransport.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SasTransport.kt @@ -59,6 +59,5 @@ internal interface SasTransport { fun createMac(tid: String, mac: Map, keys: String): VerificationInfoMac - fun createReady(tid: String, fromDevice: String, methods: List): VerificationInfoReady } diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheet.kt index 73a604e431..f4c4d6bd6e 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheet.kt @@ -84,7 +84,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - viewModel.requestLiveData.observe(this, Observer { + viewModel.requestLiveData.observe(viewLifecycleOwner, Observer { it.peekContent().let { va -> when (va) { is Success -> {