From 6fe77eba724ccad37e899365dc35cbee64874a5f Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 18 Mar 2020 11:25:49 +0100 Subject: [PATCH] code review --- .../crypto/gossiping/KeyShareTests.kt | 2 +- .../DefaultVerificationService.kt | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt index c42e94e340..c8d2df38ce 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt @@ -90,7 +90,7 @@ class KeyShareTests : InstrumentedTest { mTestHelper.retryPeriodicallyWithLatch(waitLatch) { aliceSession2.cryptoService().getOutgoingRoomKeyRequest() .filter { req -> - // filter out request thwat was known before + // filter out request that was known before !outgoingRequestBefore.any { req.requestId == it.requestId } } .let { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt index 7276debfe2..400b2c520e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt @@ -455,7 +455,7 @@ internal class DefaultVerificationService @Inject constructor( startReq: ValidVerificationInfoStart, txConfigure: (DefaultVerificationTransaction) -> Unit): CancelCode? { Timber.d("## SAS onStartRequestReceived ${startReq.transactionId}") - if (checkKeysAreDownloaded(otherUserId!!, startReq.fromDevice) != null) { + if (otherUserId?.let { checkKeysAreDownloaded(it, startReq.fromDevice) } != null) { val tid = startReq.transactionId var existing = getExistingTransaction(otherUserId, tid) @@ -469,15 +469,15 @@ internal class DefaultVerificationService @Inject constructor( if (existing != null && !existing.isIncoming) { val readyRequest = getExistingVerificationRequest(otherUserId, tid) if (readyRequest?.isReady == true) { - if (isOtherPrioritary(otherUserId, existing.otherDeviceId ?: "")) { - // The other is prioritary! - // I should replace my outgoing with an incoming - removeTransaction(otherUserId, tid) - existing = null - } else { - // i am prioritary, ignore this start event! - return null - } + if (isOtherPrioritary(otherUserId, existing.otherDeviceId ?: "")) { + // The other is prioritary! + // I should replace my outgoing with an incoming + removeTransaction(otherUserId, tid) + existing = null + } else { + // i am prioritary, ignore this start event! + return null + } } } @@ -554,7 +554,7 @@ internal class DefaultVerificationService @Inject constructor( } } - private fun isOtherPrioritary(otherUserId: String, otherDeviceId: String) : Boolean { + private fun isOtherPrioritary(otherUserId: String, otherDeviceId: String): Boolean { if (userId < otherUserId) { return false } else if (userId > otherUserId) {