Merge pull request #3461 from element-hq/feature/fga/send_failure_identity_changes

Require acknowledgement to send to a verified user if their identity changed or if a device is unverified.
This commit is contained in:
ganfra 2024-09-16 16:00:18 +02:00 committed by GitHub
commit 47d0c505b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 1355 additions and 87 deletions

View file

@ -100,7 +100,7 @@ class RustMatrixClientFactory @Inject constructor(
strategy = if (featureFlagService.isFeatureEnabled(FeatureFlags.InvisibleCrypto)) {
CollectStrategy.IdentityBasedStrategy
} else {
CollectStrategy.DeviceBasedStrategy(onlyAllowTrustedDevices = false, errorOnVerifiedUserProblem = false)
CollectStrategy.DeviceBasedStrategy(onlyAllowTrustedDevices = false, errorOnVerifiedUserProblem = true)
}
)
.run {

View file

@ -459,8 +459,8 @@ class RustMatrixRoom(
return liveTimeline.forwardEvent(eventId, roomIds)
}
override suspend fun retrySendMessage(transactionId: TransactionId): Result<Unit> {
return Result.failure(UnsupportedOperationException("Not supported"))
override suspend fun retrySendMessage(transactionId: TransactionId): Result<Unit> = runCatching {
innerRoom.tryResend(transactionId.value)
}
override suspend fun cancelSend(transactionId: TransactionId): Result<Boolean> {
@ -645,6 +645,22 @@ class RustMatrixRoom(
innerRoom.clearComposerDraft()
}
override suspend fun ignoreDeviceTrustAndResend(devices: Map<UserId, List<DeviceId>>, transactionId: TransactionId) = runCatching {
innerRoom.ignoreDeviceTrustAndResend(
devices = devices.entries.associate { entry ->
entry.key.value to entry.value.map { it.value }
},
transactionId = transactionId.value
)
}
override suspend fun withdrawVerificationAndResend(userIds: List<UserId>, transactionId: TransactionId) = runCatching {
innerRoom.withdrawVerificationAndResend(
userIds = userIds.map { it.value },
transactionId = transactionId.value
)
}
private fun createTimeline(
timeline: InnerTimeline,
mode: Timeline.Mode,

View file

@ -7,6 +7,7 @@
package io.element.android.libraries.matrix.impl.timeline.item.event
import io.element.android.libraries.matrix.api.core.DeviceId
import io.element.android.libraries.matrix.api.core.EventId
import io.element.android.libraries.matrix.api.core.TransactionId
import io.element.android.libraries.matrix.api.core.UserId
@ -87,7 +88,9 @@ fun RustEventSendState?.map(): LocalEventSendState? {
}
is RustEventSendState.VerifiedUserHasUnsignedDevice -> {
LocalEventSendState.Failed.VerifiedUserHasUnsignedDevice(
devices = devices.mapKeys { UserId(it.key) }
devices = devices.entries.associate { entry ->
UserId(entry.key) to entry.value.map { DeviceId(it) }
}
)
}
EventSendState.CrossSigningNotSetup -> LocalEventSendState.Failed.CrossSigningNotSetup