mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-02 20:26:47 +01:00
Crypto: fix a small issue
This commit is contained in:
parent
07c516ccdd
commit
f2722f4766
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.matrix.android.api.util
|
||||||
|
|
||||||
|
import arrow.core.*
|
||||||
|
|
||||||
|
inline fun <A> TryOf<A>.onError(f: (Throwable) -> Unit): Try<A> = fix()
|
||||||
|
.fold(
|
||||||
|
{
|
||||||
|
f(it)
|
||||||
|
Failure(it)
|
||||||
|
},
|
||||||
|
{ Success(it) }
|
||||||
|
)
|
@ -19,9 +19,9 @@ package im.vector.matrix.android.internal.crypto
|
|||||||
|
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import arrow.core.Try
|
import arrow.core.Try
|
||||||
import arrow.instances.`try`.applicativeError.handleError
|
|
||||||
import im.vector.matrix.android.api.MatrixPatterns
|
import im.vector.matrix.android.api.MatrixPatterns
|
||||||
import im.vector.matrix.android.api.auth.data.Credentials
|
import im.vector.matrix.android.api.auth.data.Credentials
|
||||||
|
import im.vector.matrix.android.api.util.onError
|
||||||
import im.vector.matrix.android.internal.crypto.model.MXDeviceInfo
|
import im.vector.matrix.android.internal.crypto.model.MXDeviceInfo
|
||||||
import im.vector.matrix.android.internal.crypto.model.MXUsersDevicesMap
|
import im.vector.matrix.android.internal.crypto.model.MXUsersDevicesMap
|
||||||
import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore
|
import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore
|
||||||
@ -270,10 +270,10 @@ internal class DeviceListManager(private val cryptoStore: IMXCryptoStore,
|
|||||||
Timber.v("## downloadKeys() : starts")
|
Timber.v("## downloadKeys() : starts")
|
||||||
val t0 = System.currentTimeMillis()
|
val t0 = System.currentTimeMillis()
|
||||||
doKeyDownloadForUsers(downloadUsers)
|
doKeyDownloadForUsers(downloadUsers)
|
||||||
.flatMap {
|
.map {
|
||||||
Timber.v("## downloadKeys() : doKeyDownloadForUsers succeeds after " + (System.currentTimeMillis() - t0) + " ms")
|
Timber.v("## downloadKeys() : doKeyDownloadForUsers succeeds after " + (System.currentTimeMillis() - t0) + " ms")
|
||||||
it.addEntriesFromMap(stored)
|
it.addEntriesFromMap(stored)
|
||||||
Try.just(it)
|
it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,10 +333,9 @@ internal class DeviceListManager(private val cryptoStore: IMXCryptoStore,
|
|||||||
}
|
}
|
||||||
onKeysDownloadSucceed(filteredUsers, response.failures)
|
onKeysDownloadSucceed(filteredUsers, response.failures)
|
||||||
}
|
}
|
||||||
.handleError {
|
.onError {
|
||||||
Timber.e(it, "##doKeyDownloadForUsers(): error")
|
Timber.e(it, "##doKeyDownloadForUsers(): error")
|
||||||
onKeysDownloadFailed(filteredUsers)
|
onKeysDownloadFailed(filteredUsers)
|
||||||
throw it
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +410,7 @@ internal class DeviceListManager(private val cryptoStore: IMXCryptoStore,
|
|||||||
|
|
||||||
if (!isVerified) {
|
if (!isVerified) {
|
||||||
Timber.e("## validateDeviceKeys() : Unable to verify signature on device " + userId + ":"
|
Timber.e("## validateDeviceKeys() : Unable to verify signature on device " + userId + ":"
|
||||||
+ deviceKeys.deviceId + " with error " + errorMessage)
|
+ deviceKeys.deviceId + " with error " + errorMessage)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,8 +421,8 @@ internal class DeviceListManager(private val cryptoStore: IMXCryptoStore,
|
|||||||
//
|
//
|
||||||
// Should we warn the user about it somehow?
|
// Should we warn the user about it somehow?
|
||||||
Timber.e("## validateDeviceKeys() : WARNING:Ed25519 key for device " + userId + ":"
|
Timber.e("## validateDeviceKeys() : WARNING:Ed25519 key for device " + userId + ":"
|
||||||
+ deviceKeys.deviceId + " has changed : "
|
+ deviceKeys.deviceId + " has changed : "
|
||||||
+ previouslyStoredDeviceKeys.fingerprint() + " -> " + signKey)
|
+ previouslyStoredDeviceKeys.fingerprint() + " -> " + signKey)
|
||||||
|
|
||||||
Timber.e("## validateDeviceKeys() : $previouslyStoredDeviceKeys -> $deviceKeys")
|
Timber.e("## validateDeviceKeys() : $previouslyStoredDeviceKeys -> $deviceKeys")
|
||||||
Timber.e("## validateDeviceKeys() : " + previouslyStoredDeviceKeys.keys + " -> " + deviceKeys.keys)
|
Timber.e("## validateDeviceKeys() : " + previouslyStoredDeviceKeys.keys + " -> " + deviceKeys.keys)
|
||||||
|
@ -87,7 +87,7 @@ class KeysBackupRestoreFromKeyFragment : VectorBaseFragment() {
|
|||||||
if (value.isNullOrBlank()) {
|
if (value.isNullOrBlank()) {
|
||||||
viewModel.recoveryCodeErrorText.value = context?.getString(R.string.keys_backup_recovery_code_empty_error_message)
|
viewModel.recoveryCodeErrorText.value = context?.getString(R.string.keys_backup_recovery_code_empty_error_message)
|
||||||
} else {
|
} else {
|
||||||
viewModel.recoverKeys(context!!, sharedViewModel)
|
viewModel.recoverKeys(requireContext(), sharedViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user