From 28ce915f186119bb85b82d38e4668c40922ffc05 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 13 Oct 2022 15:01:31 +0200 Subject: [PATCH] Checking current session status in the filter use case --- .../settings/devices/v2/GetDeviceFullInfoListUseCase.kt | 2 +- .../settings/devices/v2/filter/FilterDevicesUseCase.kt | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt index 42e4cebe4c..6adb33d5ab 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt @@ -57,7 +57,7 @@ class GetDeviceFullInfoListUseCase @Inject constructor( } else { emptyList() } - filterDevicesUseCase.execute(deviceFullInfoList, filterType, excludedDeviceIds) + filterDevicesUseCase.execute(currentSessionCrossSigningInfo, deviceFullInfoList, filterType, excludedDeviceIds) } deviceFullInfoFlow.distinctUntilChanged() diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/filter/FilterDevicesUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/filter/FilterDevicesUseCase.kt index a23a7a7108..8f23fd06cc 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/filter/FilterDevicesUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/filter/FilterDevicesUseCase.kt @@ -17,22 +17,27 @@ package im.vector.app.features.settings.devices.v2.filter import im.vector.app.features.settings.devices.v2.DeviceFullInfo +import im.vector.app.features.settings.devices.v2.verification.CurrentSessionCrossSigningInfo import org.matrix.android.sdk.api.extensions.orFalse import javax.inject.Inject class FilterDevicesUseCase @Inject constructor() { fun execute( + currentSessionCrossSigningInfo: CurrentSessionCrossSigningInfo, devices: List, filterType: DeviceManagerFilterType, excludedDeviceIds: List = emptyList(), ): List { + val isCurrentSessionVerified = currentSessionCrossSigningInfo.isCrossSigningVerified.orFalse() return devices .filter { when (filterType) { DeviceManagerFilterType.ALL_SESSIONS -> true - DeviceManagerFilterType.VERIFIED -> it.cryptoDeviceInfo?.trustLevel?.isCrossSigningVerified().orFalse() - DeviceManagerFilterType.UNVERIFIED -> !it.cryptoDeviceInfo?.trustLevel?.isCrossSigningVerified().orFalse() + // when current session is not verified, other session status cannot be trusted + DeviceManagerFilterType.VERIFIED -> isCurrentSessionVerified && it.cryptoDeviceInfo?.trustLevel?.isCrossSigningVerified().orFalse() + // when current session is not verified, other session status cannot be trusted + DeviceManagerFilterType.UNVERIFIED -> isCurrentSessionVerified && !it.cryptoDeviceInfo?.trustLevel?.isCrossSigningVerified().orFalse() DeviceManagerFilterType.INACTIVE -> it.isInactive } }