From 38644f0aa29211a669cfbb7d754b337d4860814f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 24 Nov 2021 14:35:52 +0100 Subject: [PATCH] crypto: Rewrap and use the new isUserTracked method --- .../sdk/internal/crypto/DefaultCryptoService.kt | 6 +++++- .../matrix/android/sdk/internal/crypto/OlmMachine.kt | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt index a87d2483e0..70e792d4f6 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt @@ -255,7 +255,11 @@ internal class DefaultCryptoService @Inject constructor( * @return the tracking status */ override fun getDeviceTrackingStatus(userId: String): Int { - return cryptoStore.getDeviceTrackingStatus(userId, DeviceListManager.TRACKING_STATUS_NOT_TRACKED) + return if (olmMachine.isUserTracked(userId)) { + 3 + } else { + -1 + } } /** diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt index 710490b372..2d503c1df0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt @@ -332,6 +332,17 @@ internal class OlmMachine( suspend fun updateTrackedUsers(users: List) = withContext(Dispatchers.IO) { inner.updateTrackedUsers(users) } + + /** + * Check if the given user is considered to be tracked. + * A user can be marked for tracking using the + * [OlmMachine.updateTrackedUsers] method. + */ + @Throws(CryptoStoreException::class) + fun isUserTracked(userId: String): Boolean { + return this.inner.isUserTracked(userId) + } + /** * Generate one-time key claiming requests for all the users we are missing sessions for. *