mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-28 03:48:37 +03:00
Use new isUserTracked API
This commit is contained in:
parent
9118b26d2f
commit
7fd9ca03be
1 changed files with 13 additions and 13 deletions
|
@ -334,7 +334,6 @@ internal class OlmMachine(
|
||||||
suspend fun updateTrackedUsers(users: List<String>) =
|
suspend fun updateTrackedUsers(users: List<String>) =
|
||||||
withContext(Dispatchers.IO) { inner.updateTrackedUsers(users) }
|
withContext(Dispatchers.IO) { inner.updateTrackedUsers(users) }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the given user is considered to be tracked.
|
* Check if the given user is considered to be tracked.
|
||||||
* A user can be marked for tracking using the
|
* A user can be marked for tracking using the
|
||||||
|
@ -647,14 +646,12 @@ internal class OlmMachine(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws
|
@Throws
|
||||||
suspend fun forceKeyDownload(userIds: List<String>): MXUsersDevicesMap<CryptoDeviceInfo> {
|
suspend fun forceKeyDownload(userIds: List<String>) {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
val requestId = UUID.randomUUID().toString()
|
val requestId = UUID.randomUUID().toString()
|
||||||
val response = requestSender.queryKeys(Request.KeysQuery(requestId, userIds))
|
val response = requestSender.queryKeys(Request.KeysQuery(requestId, userIds))
|
||||||
markRequestAsSent(requestId, RequestType.KEYS_QUERY, response)
|
markRequestAsSent(requestId, RequestType.KEYS_QUERY, response)
|
||||||
}
|
}
|
||||||
// TODO notify shield listener (?)
|
|
||||||
return getUserDevicesMap(userIds)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getUserDevicesMap(userIds: List<String>): MXUsersDevicesMap<CryptoDeviceInfo> {
|
suspend fun getUserDevicesMap(userIds: List<String>): MXUsersDevicesMap<CryptoDeviceInfo> {
|
||||||
|
@ -674,20 +671,23 @@ internal class OlmMachine(
|
||||||
/**
|
/**
|
||||||
* If the user is untracked or forceDownload is set to true, a key query request will be made.
|
* If the user is untracked or forceDownload is set to true, a key query request will be made.
|
||||||
* It will suspend until query response, and the device list will be returned.
|
* It will suspend until query response, and the device list will be returned.
|
||||||
* As there is no API to know tracking status, we consider that if there are no known devices the user is un tracked.
|
|
||||||
*
|
*
|
||||||
* The key query request will be retried a few time in case of shaky connection, but could fail.
|
* The key query request will be retried a few time in case of shaky connection, but could fail.
|
||||||
*/
|
*/
|
||||||
suspend fun ensureUserDevicesMap(userIds: List<String>, forceDownload: Boolean = false): MXUsersDevicesMap<CryptoDeviceInfo> {
|
suspend fun ensureUserDevicesMap(userIds: List<String>, forceDownload: Boolean = false): MXUsersDevicesMap<CryptoDeviceInfo> {
|
||||||
val known = getUserDevicesMap(userIds)
|
val toDownload = if (forceDownload) {
|
||||||
return if (known.isEmpty /* We have no api to know if was tracked..*/ || forceDownload) {
|
userIds
|
||||||
updateTrackedUsers(userIds)
|
|
||||||
tryOrNull("Failed to download keys for $userIds") {
|
|
||||||
forceKeyDownload(userIds)
|
|
||||||
} ?: known
|
|
||||||
} else {
|
} else {
|
||||||
known
|
userIds.mapNotNull { userId ->
|
||||||
|
userId.takeIf { !isUserTracked(it) }
|
||||||
|
}.also {
|
||||||
|
updateTrackedUsers(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
tryOrNull("Failed to download keys for $toDownload") {
|
||||||
|
forceKeyDownload(toDownload)
|
||||||
|
}
|
||||||
|
return getUserDevicesMap(userIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getLiveUserIdentity(userId: String): LiveData<Optional<MXCrossSigningInfo>> {
|
suspend fun getLiveUserIdentity(userId: String): LiveData<Optional<MXCrossSigningInfo>> {
|
||||||
|
@ -795,7 +795,7 @@ internal class OlmMachine(
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun bootstrapCrossSigning(uiaInterceptor: UserInteractiveAuthInterceptor?) {
|
suspend fun bootstrapCrossSigning(uiaInterceptor: UserInteractiveAuthInterceptor?) {
|
||||||
val requests = withContext(Dispatchers.IO) {
|
val requests = withContext(Dispatchers.IO) {
|
||||||
inner.bootstrapCrossSigning()
|
inner.bootstrapCrossSigning()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue