Send failure verified user : add some comments and logs.
This commit is contained in:
parent
ca59e1f51e
commit
6c29b5c694
4 changed files with 38 additions and 3 deletions
|
|
@ -118,7 +118,7 @@ private fun VerifiedUserSendFailure.title(): String {
|
||||||
id = CommonStrings.screen_resolve_send_failure_changed_identity_title,
|
id = CommonStrings.screen_resolve_send_failure_changed_identity_title,
|
||||||
userDisplayName
|
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,
|
id = CommonStrings.screen_resolve_send_failure_changed_identity_subtitle,
|
||||||
userDisplayName
|
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) {
|
return when (this) {
|
||||||
is VerifiedUserSendFailure.UnsignedDevice -> stringResource(id = CommonStrings.screen_resolve_send_failure_unsigned_device_primary_button_title)
|
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)
|
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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
package io.element.android.features.messages.impl.crypto.sendfailure.resolve
|
package io.element.android.features.messages.impl.crypto.sendfailure.resolve
|
||||||
|
|
||||||
import io.element.android.libraries.matrix.api.timeline.item.event.LocalEventSendState
|
import io.element.android.libraries.matrix.api.timeline.item.event.LocalEventSendState
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterator for [LocalEventSendState.Failed.VerifiedUser]
|
* Iterator for [LocalEventSendState.Failed.VerifiedUser]
|
||||||
|
|
@ -30,6 +31,12 @@ class UnsignedDeviceSendFailureIterator(
|
||||||
) : VerifiedUserSendFailureIterator {
|
) : VerifiedUserSendFailureIterator {
|
||||||
private val iterator = failure.devices.iterator()
|
private val iterator = failure.devices.iterator()
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (!hasNext()) {
|
||||||
|
Timber.w("Got $failure without any devices, shouldn't happen.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun hasNext(): Boolean {
|
override fun hasNext(): Boolean {
|
||||||
return iterator.hasNext()
|
return iterator.hasNext()
|
||||||
}
|
}
|
||||||
|
|
@ -47,6 +54,12 @@ class ChangedIdentitySendFailureIterator(
|
||||||
) : VerifiedUserSendFailureIterator {
|
) : VerifiedUserSendFailureIterator {
|
||||||
private val iterator = failure.users.iterator()
|
private val iterator = failure.users.iterator()
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (!hasNext()) {
|
||||||
|
Timber.w("Got $failure without any users, shouldn't happen.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun hasNext(): Boolean {
|
override fun hasNext(): Boolean {
|
||||||
return iterator.hasNext()
|
return iterator.hasNext()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 io.element.android.libraries.matrix.api.timeline.item.event.LocalEventSendState
|
||||||
import timber.log.Timber
|
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(
|
class VerifiedUserSendFailureResolver(
|
||||||
private val room: MatrixRoom,
|
private val room: MatrixRoom,
|
||||||
private val transactionId: TransactionId,
|
private val transactionId: TransactionId,
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,23 @@ interface MatrixRoom : Closeable {
|
||||||
*/
|
*/
|
||||||
suspend fun clearComposerDraft(): Result<Unit>
|
suspend fun clearComposerDraft(): Result<Unit>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ignore the local trust for the given devices and resend messages that failed to send because said devices are unverified.
|
||||||
|
*
|
||||||
|
* @param devices The map of users identifiers to device identifiers received in the error
|
||||||
|
* @param transactionId The send queue transaction identifier of the local echo the send error applies to.
|
||||||
|
*
|
||||||
|
*/
|
||||||
suspend fun ignoreDeviceTrustAndResend(devices: Map<UserId, List<DeviceId>>, transactionId: TransactionId): Result<Unit>
|
suspend fun ignoreDeviceTrustAndResend(devices: Map<UserId, List<DeviceId>>, transactionId: TransactionId): Result<Unit>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove verification requirements for the given users and
|
||||||
|
* resend messages that failed to send because their identities were no longer verified.
|
||||||
|
*
|
||||||
|
* @param userIds The list of users identifiers received in the error.
|
||||||
|
* @param transactionId The send queue transaction identifier of the local echo the send error applies to.
|
||||||
|
*
|
||||||
|
*/
|
||||||
suspend fun withdrawVerificationAndResend(userIds: List<UserId>, transactionId: TransactionId): Result<Unit>
|
suspend fun withdrawVerificationAndResend(userIds: List<UserId>, transactionId: TransactionId): Result<Unit>
|
||||||
|
|
||||||
override fun close() = destroy()
|
override fun close() = destroy()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue