diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt index 1763385b76..e8392b745f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt @@ -854,10 +854,6 @@ private fun List?.toRemote(): List { } private fun BackupMessageRecord.toRemoteSendStatus(groupReceipts: List?): List { - if (!MessageTypes.isOutgoingMessageType(this.type)) { - return emptyList() - } - if (!groupReceipts.isNullOrEmpty()) { return groupReceipts.toRemoteSendStatus(this, this.networkFailureRecipientIds, this.identityMismatchRecipientIds) } @@ -925,12 +921,12 @@ private fun List.toRemoteSendStatus(messageR reason = SendStatus.Failed.FailureReason.IDENTITY_KEY_MISMATCH ) } - networkFailureRecipientIds.contains(it.recipientId.toLong()) -> { + MessageTypes.isFailedMessageType(messageRecord.type) && networkFailureRecipientIds.contains(it.recipientId.toLong()) -> { statusBuilder.failed = SendStatus.Failed( reason = SendStatus.Failed.FailureReason.NETWORK ) } - messageRecord.baseType == MessageTypes.BASE_SENT_FAILED_TYPE -> { + MessageTypes.isFailedMessageType(messageRecord.type) -> { statusBuilder.failed = SendStatus.Failed( reason = SendStatus.Failed.FailureReason.UNKNOWN ) diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/importer/ChatItemArchiveImporter.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/importer/ChatItemArchiveImporter.kt index b32a19ecfa..a308777d2f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/importer/ChatItemArchiveImporter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/importer/ChatItemArchiveImporter.kt @@ -578,21 +578,16 @@ class ChatItemArchiveImporter( private fun ChatItem.getMessageType(): Long { var type: Long = if (this.outgoing != null) { - if (this.outgoing.sendStatus.count { it.failed?.reason == SendStatus.Failed.FailureReason.IDENTITY_KEY_MISMATCH } > 0) { + if (this.outgoing.sendStatus.any { it.failed?.reason == SendStatus.Failed.FailureReason.IDENTITY_KEY_MISMATCH }) { MessageTypes.BASE_SENT_FAILED_TYPE - } else if (this.outgoing.sendStatus.count { it.failed?.reason == SendStatus.Failed.FailureReason.UNKNOWN } > 0) { + } else if (this.outgoing.sendStatus.any { it.failed?.reason == SendStatus.Failed.FailureReason.UNKNOWN }) { MessageTypes.BASE_SENT_FAILED_TYPE - } else if (this.outgoing.sendStatus.count { it.failed?.reason == SendStatus.Failed.FailureReason.NETWORK } > 0) { + } else if (this.outgoing.sendStatus.any { it.failed?.reason == SendStatus.Failed.FailureReason.NETWORK }) { + MessageTypes.BASE_SENT_FAILED_TYPE + } else if (this.outgoing.sendStatus.any { it.pending != null }) { MessageTypes.BASE_SENDING_TYPE - } else if (this.outgoing.sendStatus.count { it.pending != null } > 0) { - MessageTypes.BASE_SENDING_TYPE - } else if (this.outgoing.sendStatus.count { it.skipped != null } > 0) { - val count = this.outgoing.sendStatus.count { it.skipped != null } - if (count == this.outgoing.sendStatus.size) { - MessageTypes.BASE_SENDING_SKIPPED_TYPE - } else { - MessageTypes.BASE_SENDING_TYPE - } + } else if (this.outgoing.sendStatus.all { it.skipped != null }) { + MessageTypes.BASE_SENDING_SKIPPED_TYPE } else { MessageTypes.BASE_SENT_TYPE }