Remove legacy manually verify specific other device

This commit is contained in:
valere 2023-05-22 22:26:26 +02:00
parent aecdd475d8
commit 517af968e6
8 changed files with 12 additions and 60 deletions

View file

@ -2465,7 +2465,9 @@
<string name="verification_profile_device_verified_because">This session is trusted for secure messaging because %1$s (%2$s) verified it:</string>
<string name="verification_profile_device_new_signing">%1$s (%2$s) signed in using a new session:</string>
<string name="verification_profile_device_untrust_info">Until this user trusts this session, messages sent to and from it are labeled with warnings. Alternatively, you can manually verify it.</string>
<!-- TODO TO BE REMOVED -->
<string tools:ignore="UnusedResources" name="verification_profile_device_untrust_info">Until this user trusts this session, messages sent to and from it are labeled with warnings. Alternatively, you can manually verify it.</string>
<string name="verification_profile_other_device_untrust_info">Until this user trusts this session, messages sent to and from it are labeled with warnings.</string>
<string name="initialize_cross_signing">Initialize CrossSigning</string>

View file

@ -22,6 +22,4 @@ import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
sealed class DeviceListAction : VectorViewModelAction {
data class SelectDevice(val device: CryptoDeviceInfo) : DeviceListAction()
object DeselectDevice : DeviceListAction()
data class ManuallyVerify(val deviceId: String) : DeviceListAction()
}

View file

@ -47,16 +47,7 @@ class DeviceListBottomSheet :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewModel.observeViewEvents {
when (it) {
is DeviceListBottomSheetViewEvents.Verify -> {
// TODO selfverif
// VerificationBottomSheet.withArgs(
// // roomId = null,
// otherUserId = it.userId,
// transactionId = it.txID
// ).show(requireActivity().supportFragmentManager, "REQPOP")
}
}
// nop
}
}

View file

@ -21,6 +21,4 @@ import im.vector.app.core.platform.VectorViewEvents
/**
* Transient events for device list screen.
*/
sealed class DeviceListBottomSheetViewEvents : VectorViewEvents {
data class Verify(val userId: String, val txID: String) : DeviceListBottomSheetViewEvents()
}
sealed class DeviceListBottomSheetViewEvents : VectorViewEvents

View file

@ -34,7 +34,6 @@ import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
import org.matrix.android.sdk.api.session.getUserOrDefault
import org.matrix.android.sdk.api.util.MatrixItem
import org.matrix.android.sdk.api.util.toMatrixItem
@ -42,7 +41,7 @@ import org.matrix.android.sdk.flow.flow
data class DeviceListViewState(
val userId: String,
val allowDeviceAction: Boolean,
val myUserId: String,
val userItem: MatrixItem? = null,
val memberCrossSigningKey: MXCrossSigningInfo? = null,
val myDeviceId: String = "",
@ -69,7 +68,7 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
val session = EntryPoints.get(viewModelContext.app(), SingletonEntryPoint::class.java).activeSessionHolder().getActiveSession()
return DeviceListViewState(
userId = userId,
allowDeviceAction = args.allowDeviceAction,
myUserId = session.myUserId,
userItem = session.getUserOrDefault(userId).toMatrixItem(),
myDeviceId = session.sessionParams.deviceId,
)
@ -104,7 +103,6 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
when (action) {
is DeviceListAction.SelectDevice -> selectDevice(action)
is DeviceListAction.DeselectDevice -> deselectDevice()
is DeviceListAction.ManuallyVerify -> manuallyVerify(action)
}
}
@ -121,7 +119,6 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
}
private fun selectDevice(action: DeviceListAction.SelectDevice) {
if (!initialState.allowDeviceAction) return
setState {
copy(selectedDevice = action.device)
}
@ -132,18 +129,4 @@ class DeviceListBottomSheetViewModel @AssistedInject constructor(
copy(selectedDevice = null)
}
}
private fun manuallyVerify(action: DeviceListAction.ManuallyVerify) {
if (!initialState.allowDeviceAction) return
viewModelScope.launch {
session.cryptoService().verificationService().requestDeviceVerification(
methods = listOf(VerificationMethod.SAS),
otherUserId = initialState.userId,
otherDeviceId = action.deviceId,
).transactionId
.let { txID ->
_viewEvents.post(DeviceListBottomSheetViewEvents.Verify(initialState.userId, txID))
}
}
}
}

View file

@ -28,7 +28,6 @@ import im.vector.app.core.extensions.configureWith
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.databinding.BottomSheetGenericListBinding
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
import javax.inject.Inject
@AndroidEntryPoint
@ -63,8 +62,4 @@ class DeviceTrustInfoActionFragment :
override fun invalidate() = withState(viewModel) {
epoxyController.setData(it)
}
override fun onVerifyManually(device: CryptoDeviceInfo) {
viewModel.handle(DeviceListAction.ManuallyVerify(device.deviceId))
}
}

View file

@ -25,13 +25,10 @@ import im.vector.app.core.ui.list.genericFooterItem
import im.vector.app.core.ui.list.genericItem
import im.vector.app.core.ui.list.genericWithValueItem
import im.vector.app.core.utils.DimensionConverter
import im.vector.app.features.crypto.verification.epoxy.bottomSheetVerificationActionItem
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.settings.devices.TrustUtils
import im.vector.lib.core.utils.epoxy.charsequence.toEpoxyCharSequence
import me.gujun.android.span.span
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
import javax.inject.Inject
@ -39,13 +36,10 @@ class DeviceTrustInfoEpoxyController @Inject constructor(
private val stringProvider: StringProvider,
private val colorProvider: ColorProvider,
private val dimensionConverter: DimensionConverter,
private val vectorPreferences: VectorPreferences
) :
TypedEpoxyController<DeviceListViewState>() {
interface InteractionListener {
fun onVerifyManually(device: CryptoDeviceInfo)
}
interface InteractionListener
var interactionListener: InteractionListener? = null
@ -54,7 +48,7 @@ class DeviceTrustInfoEpoxyController @Inject constructor(
data?.selectedDevice?.let { cryptoDeviceInfo ->
val trustMSK = data.memberCrossSigningKey?.isTrusted().orFalse()
val legacyMode = data.memberCrossSigningKey == null
val isMyDevice = data.myDeviceId == cryptoDeviceInfo.deviceId
val isMyDevice = data.userId == data.myUserId && data.myDeviceId == cryptoDeviceInfo.deviceId
val trustLevel = TrustUtils.shieldForTrust(
isMyDevice,
trustMSK,
@ -126,18 +120,7 @@ class DeviceTrustInfoEpoxyController @Inject constructor(
id("warn")
centered(false)
textColor(host.colorProvider.getColorFromAttribute(R.attr.vctr_content_primary))
text(host.stringProvider.getString(R.string.verification_profile_device_untrust_info).toEpoxyCharSequence())
}
bottomSheetVerificationActionItem {
id("verify")
title(host.stringProvider.getString(R.string.cross_signing_verify_by_emoji))
titleColor(host.colorProvider.getColorFromAttribute(R.attr.colorPrimary))
iconRes(R.drawable.ic_arrow_right)
iconColor(host.colorProvider.getColorFromAttribute(R.attr.colorPrimary))
listener {
host.interactionListener?.onVerifyManually(cryptoDeviceInfo)
}
text(host.stringProvider.getString(R.string.verification_profile_other_device_untrust_info).toEpoxyCharSequence())
}
}
}

View file

@ -22,6 +22,8 @@ import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
// TODO Replace usage by the use case GetEncryptionTrustLevelForDeviceUseCase
object TrustUtils {
// XXX why is this using the RoomEncryptionTrustLevel?
// should be using a new DeviceTrustShield enum
fun shieldForTrust(
currentDevice: Boolean,
trustMSK: Boolean,