Checking current session status in the filter use case
This commit is contained in:
parent
f77bceb918
commit
28ce915f18
|
@ -57,7 +57,7 @@ class GetDeviceFullInfoListUseCase @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
filterDevicesUseCase.execute(deviceFullInfoList, filterType, excludedDeviceIds)
|
filterDevicesUseCase.execute(currentSessionCrossSigningInfo, deviceFullInfoList, filterType, excludedDeviceIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceFullInfoFlow.distinctUntilChanged()
|
deviceFullInfoFlow.distinctUntilChanged()
|
||||||
|
|
|
@ -17,22 +17,27 @@
|
||||||
package im.vector.app.features.settings.devices.v2.filter
|
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.DeviceFullInfo
|
||||||
|
import im.vector.app.features.settings.devices.v2.verification.CurrentSessionCrossSigningInfo
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FilterDevicesUseCase @Inject constructor() {
|
class FilterDevicesUseCase @Inject constructor() {
|
||||||
|
|
||||||
fun execute(
|
fun execute(
|
||||||
|
currentSessionCrossSigningInfo: CurrentSessionCrossSigningInfo,
|
||||||
devices: List<DeviceFullInfo>,
|
devices: List<DeviceFullInfo>,
|
||||||
filterType: DeviceManagerFilterType,
|
filterType: DeviceManagerFilterType,
|
||||||
excludedDeviceIds: List<String> = emptyList(),
|
excludedDeviceIds: List<String> = emptyList(),
|
||||||
): List<DeviceFullInfo> {
|
): List<DeviceFullInfo> {
|
||||||
|
val isCurrentSessionVerified = currentSessionCrossSigningInfo.isCrossSigningVerified.orFalse()
|
||||||
return devices
|
return devices
|
||||||
.filter {
|
.filter {
|
||||||
when (filterType) {
|
when (filterType) {
|
||||||
DeviceManagerFilterType.ALL_SESSIONS -> true
|
DeviceManagerFilterType.ALL_SESSIONS -> true
|
||||||
DeviceManagerFilterType.VERIFIED -> it.cryptoDeviceInfo?.trustLevel?.isCrossSigningVerified().orFalse()
|
// when current session is not verified, other session status cannot be trusted
|
||||||
DeviceManagerFilterType.UNVERIFIED -> !it.cryptoDeviceInfo?.trustLevel?.isCrossSigningVerified().orFalse()
|
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
|
DeviceManagerFilterType.INACTIVE -> it.isInactive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue