Merge pull request #1338 from vector-im/feature/crash_manual_verify

Crashes when private key missing
This commit is contained in:
Valere 2020-05-13 16:35:38 +02:00 committed by GitHub
commit 074a9e9f29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -10,6 +10,7 @@ Improvements 🙌:
- Support homeserver discovery from MXID (DISABLED: waiting for design) (#476) - Support homeserver discovery from MXID (DISABLED: waiting for design) (#476)
Bugfix 🐛: Bugfix 🐛:
- Fix | Verify Manually by Text crashes if private SSK not known (#1337)
- Sometimes the same device appears twice in the list of devices of a user (#1329) - Sometimes the same device appears twice in the list of devices of a user (#1329)
Translations 🗣: Translations 🗣:

View File

@ -30,7 +30,6 @@ import com.squareup.inject.assisted.Assisted
import com.squareup.inject.assisted.AssistedInject import com.squareup.inject.assisted.AssistedInject
import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.MatrixCallback
import im.vector.matrix.android.api.NoOpMatrixCallback import im.vector.matrix.android.api.NoOpMatrixCallback
import im.vector.matrix.android.api.extensions.tryThis
import im.vector.matrix.android.api.failure.Failure import im.vector.matrix.android.api.failure.Failure
import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.Session
import im.vector.matrix.android.api.session.crypto.verification.VerificationMethod import im.vector.matrix.android.api.session.crypto.verification.VerificationMethod
@ -48,6 +47,7 @@ import io.reactivex.Observable
import io.reactivex.functions.BiFunction import io.reactivex.functions.BiFunction
import io.reactivex.subjects.PublishSubject import io.reactivex.subjects.PublishSubject
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import timber.log.Timber
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
data class DevicesViewState( data class DevicesViewState(
@ -65,6 +65,7 @@ data class DeviceFullInfo(
val deviceInfo: DeviceInfo, val deviceInfo: DeviceInfo,
val cryptoDeviceInfo: CryptoDeviceInfo? val cryptoDeviceInfo: CryptoDeviceInfo?
) )
class DevicesViewModel @AssistedInject constructor( class DevicesViewModel @AssistedInject constructor(
@Assisted initialState: DevicesViewState, @Assisted initialState: DevicesViewState,
private val session: Session private val session: Session
@ -215,8 +216,13 @@ class DevicesViewModel @AssistedInject constructor(
private fun handleVerifyManually(action: DevicesAction.MarkAsManuallyVerified) = withState { state -> private fun handleVerifyManually(action: DevicesAction.MarkAsManuallyVerified) = withState { state ->
viewModelScope.launch { viewModelScope.launch {
if (state.hasAccountCrossSigning) { if (state.hasAccountCrossSigning) {
awaitCallback<Unit> { try {
tryThis { session.cryptoService().crossSigningService().trustDevice(action.cryptoDeviceInfo.deviceId, it) } awaitCallback<Unit> {
session.cryptoService().crossSigningService().trustDevice(action.cryptoDeviceInfo.deviceId, it)
}
} catch (failure: Throwable) {
Timber.e("Failed to manually cross sign device ${action.cryptoDeviceInfo.deviceId} : ${failure.localizedMessage}")
_viewEvents.post(DevicesViewEvents.Failure(failure))
} }
} else { } else {
// legacy // legacy