Send failure verified user : add some comments and logs.

This commit is contained in:
ganfra
2024-09-16 15:22:40 +02:00
parent ca59e1f51e
commit 6c29b5c694
4 changed files with 38 additions and 3 deletions

View File

@@ -118,7 +118,7 @@ private fun VerifiedUserSendFailure.title(): String {
id = CommonStrings.screen_resolve_send_failure_changed_identity_title,
userDisplayName
)
VerifiedUserSendFailure.None -> ""
VerifiedUserSendFailure.None -> error("This method should never be called for this state")
}
}
@@ -134,7 +134,7 @@ private fun VerifiedUserSendFailure.subtitle(): String {
id = CommonStrings.screen_resolve_send_failure_changed_identity_subtitle,
userDisplayName
)
VerifiedUserSendFailure.None -> ""
VerifiedUserSendFailure.None -> error("This method should never be called for this state")
}
}
@@ -143,7 +143,7 @@ private fun VerifiedUserSendFailure.resolveAction(): String {
return when (this) {
is VerifiedUserSendFailure.UnsignedDevice -> stringResource(id = CommonStrings.screen_resolve_send_failure_unsigned_device_primary_button_title)
is VerifiedUserSendFailure.ChangedIdentity -> stringResource(id = CommonStrings.screen_resolve_send_failure_changed_identity_primary_button_title)
VerifiedUserSendFailure.None -> ""
VerifiedUserSendFailure.None -> error("This method should never be called for this state")
}
}

View File

@@ -8,6 +8,7 @@
package io.element.android.features.messages.impl.crypto.sendfailure.resolve
import io.element.android.libraries.matrix.api.timeline.item.event.LocalEventSendState
import timber.log.Timber
/**
* Iterator for [LocalEventSendState.Failed.VerifiedUser]
@@ -30,6 +31,12 @@ class UnsignedDeviceSendFailureIterator(
) : VerifiedUserSendFailureIterator {
private val iterator = failure.devices.iterator()
init {
if (!hasNext()) {
Timber.w("Got $failure without any devices, shouldn't happen.")
}
}
override fun hasNext(): Boolean {
return iterator.hasNext()
}
@@ -47,6 +54,12 @@ class ChangedIdentitySendFailureIterator(
) : VerifiedUserSendFailureIterator {
private val iterator = failure.users.iterator()
init {
if (!hasNext()) {
Timber.w("Got $failure without any users, shouldn't happen.")
}
}
override fun hasNext(): Boolean {
return iterator.hasNext()
}

View File

@@ -13,6 +13,12 @@ import io.element.android.libraries.matrix.api.room.MatrixRoom
import io.element.android.libraries.matrix.api.timeline.item.event.LocalEventSendState
import timber.log.Timber
/**
* This class is responsible for resolving and resending a failed message sent to a verified user.
* It also allow to resend the message without resolving the failure, for example if the user has in the meantime verified their device again.
* It's using the [VerifiedUserSendFailureIterator] to iterate over the different failures (ie. the different users concerned by the failure).
* This way, the user can resolve and resend the message for each user concerned, one by one.
*/
class VerifiedUserSendFailureResolver(
private val room: MatrixRoom,
private val transactionId: TransactionId,