mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 06:28:45 +03:00
crypto: Get rid of the DeviceKeysManager
This commit is contained in:
parent
08d0787cc9
commit
edfd1b2fe0
2 changed files with 22 additions and 7 deletions
|
@ -122,8 +122,6 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
private val cryptoStore: IMXCryptoStore,
|
||||
// Set of parameters used to configure/customize the end-to-end crypto.
|
||||
private val mxCryptoConfig: MXCryptoConfig,
|
||||
// Device list manager
|
||||
private val deviceListManager: DeviceListManager,
|
||||
// The key backup service.
|
||||
private val keysBackupService: DefaultKeysBackupService,
|
||||
// The verification service.
|
||||
|
@ -915,7 +913,13 @@ internal class DefaultCryptoService @Inject constructor(
|
|||
override fun downloadKeys(userIds: List<String>, forceDownload: Boolean, callback: MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>>) {
|
||||
cryptoCoroutineScope.launch(coroutineDispatchers.crypto) {
|
||||
runCatching {
|
||||
deviceListManager.downloadKeys(userIds, forceDownload)
|
||||
if (forceDownload) {
|
||||
// TODO replicate the logic from the device list manager
|
||||
// where we would download the fresh info from the server.
|
||||
olmMachine?.getUserDevicesMap(userIds) ?: MXUsersDevicesMap()
|
||||
} else {
|
||||
olmMachine?.getUserDevicesMap(userIds) ?: MXUsersDevicesMap()
|
||||
}
|
||||
}.foldToCallback(callback)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.matrix.android.sdk.api.util.JsonDict
|
|||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
||||
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
||||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.UnsignedDeviceInfo
|
||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||
import org.matrix.android.sdk.internal.session.sync.model.DeviceListResponse
|
||||
|
@ -213,7 +214,6 @@ internal class OlmMachine(user_id: String, device_id: String, path: File) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Let the state machine know about E2EE related sync changes that we
|
||||
* received from the server.
|
||||
|
@ -261,7 +261,6 @@ internal class OlmMachine(user_id: String, device_id: String, path: File) {
|
|||
inner.updateTrackedUsers(users)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate one-time key claiming requests for all the users we are missing
|
||||
* sessions for.
|
||||
|
@ -394,7 +393,6 @@ internal class OlmMachine(user_id: String, device_id: String, path: File) {
|
|||
inner.exportKeys(passphrase, rounds).toByteArray()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Import room keys from the given serialized key export.
|
||||
*
|
||||
|
@ -416,7 +414,6 @@ internal class OlmMachine(user_id: String, device_id: String, path: File) {
|
|||
ImportRoomKeysResult(result.total, result.imported)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a `Device` from the store.
|
||||
*
|
||||
|
@ -444,6 +441,20 @@ internal class OlmMachine(user_id: String, device_id: String, path: File) {
|
|||
return inner.getUserDevices(userId).map { Device(it, inner).toCryptoDeviceInfo() }
|
||||
}
|
||||
|
||||
suspend fun getUserDevicesMap(userIds: List<String>): MXUsersDevicesMap<CryptoDeviceInfo> {
|
||||
val userMap = MXUsersDevicesMap<CryptoDeviceInfo>()
|
||||
|
||||
for (user in userIds) {
|
||||
val devices = getUserDevices(user)
|
||||
|
||||
for (device in devices) {
|
||||
userMap.setObject(user, device.deviceId, device)
|
||||
}
|
||||
}
|
||||
|
||||
return userMap
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the devices of multiple users.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue