mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-25 05:27:42 +00:00
Fix group receipt handling in backups.
This commit is contained in:
@@ -53,7 +53,7 @@ class ArchiveImportExportTests {
|
||||
|
||||
@Test
|
||||
fun temp() {
|
||||
runTests { it == "account_data_01.binproto" }
|
||||
runTests { it == "chat_item_standard_message_formatted_text_03.binproto" }
|
||||
}
|
||||
|
||||
// Passing
|
||||
@@ -73,7 +73,8 @@ class ArchiveImportExportTests {
|
||||
runTests { it.startsWith("chat_") && !it.contains("_item") }
|
||||
}
|
||||
|
||||
@Test
|
||||
// Passing
|
||||
// @Test
|
||||
fun chatItemContactMessage() {
|
||||
runTests { it.startsWith("chat_item_contact_message_") }
|
||||
}
|
||||
@@ -134,7 +135,8 @@ class ArchiveImportExportTests {
|
||||
runTests { it.startsWith("chat_item_simple_updates_") }
|
||||
}
|
||||
|
||||
@Test
|
||||
// Passing
|
||||
// @Test
|
||||
fun chatItemStandardMessageFormattedText() {
|
||||
runTests { it.startsWith("chat_item_standard_message_formatted_text_") }
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||
directionless = ChatItem.DirectionlessMessageDetails()
|
||||
} else if (MessageTypes.isOutgoingMessageType(record.type)) {
|
||||
outgoing = ChatItem.OutgoingMessageDetails(
|
||||
sendStatus = record.toBackupSendStatus(groupReceipts)
|
||||
sendStatus = record.toRemoteSendStatus(groupReceipts)
|
||||
)
|
||||
} else {
|
||||
incoming = ChatItem.IncomingMessageDetails(
|
||||
@@ -875,13 +875,13 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
private fun BackupMessageRecord.toBackupSendStatus(groupReceipts: List<GroupReceiptTable.GroupReceiptInfo>?): List<SendStatus> {
|
||||
private fun BackupMessageRecord.toRemoteSendStatus(groupReceipts: List<GroupReceiptTable.GroupReceiptInfo>?): List<SendStatus> {
|
||||
if (!MessageTypes.isOutgoingMessageType(this.type)) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
if (!groupReceipts.isNullOrEmpty()) {
|
||||
return groupReceipts.toBackupSendStatus(this.networkFailureRecipientIds, this.identityMismatchRecipientIds)
|
||||
return groupReceipts.toRemoteSendStatus(this, this.networkFailureRecipientIds, this.identityMismatchRecipientIds)
|
||||
}
|
||||
|
||||
val statusBuilder = SendStatus.Builder()
|
||||
@@ -935,7 +935,7 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||
return listOf(statusBuilder.build())
|
||||
}
|
||||
|
||||
private fun List<GroupReceiptTable.GroupReceiptInfo>.toBackupSendStatus(networkFailureRecipientIds: Set<Long>, identityMismatchRecipientIds: Set<Long>): List<SendStatus> {
|
||||
private fun List<GroupReceiptTable.GroupReceiptInfo>.toRemoteSendStatus(messageRecord: BackupMessageRecord, networkFailureRecipientIds: Set<Long>, identityMismatchRecipientIds: Set<Long>): List<SendStatus> {
|
||||
return this.map {
|
||||
val statusBuilder = SendStatus.Builder()
|
||||
.recipientId(it.recipientId.toLong())
|
||||
@@ -952,6 +952,11 @@ class ChatItemExportIterator(private val cursor: Cursor, private val batchSize:
|
||||
reason = SendStatus.Failed.FailureReason.NETWORK
|
||||
)
|
||||
}
|
||||
messageRecord.baseType == MessageTypes.BASE_SENT_FAILED_TYPE -> {
|
||||
statusBuilder.failed = SendStatus.Failed(
|
||||
reason = SendStatus.Failed.FailureReason.UNKNOWN
|
||||
)
|
||||
}
|
||||
it.status == GroupReceiptTable.STATUS_UNKNOWN -> {
|
||||
statusBuilder.pending = SendStatus.Pending()
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ class ChatItemImportInserter(
|
||||
GroupReceiptTable.RECIPIENT_ID to recipientId.serialize(),
|
||||
GroupReceiptTable.STATUS to sendStatus.toLocalSendStatus(),
|
||||
GroupReceiptTable.TIMESTAMP to sendStatus.timestamp,
|
||||
GroupReceiptTable.UNIDENTIFIED to sendStatus.sealedSender
|
||||
GroupReceiptTable.UNIDENTIFIED to sendStatus.sealedSender.toInt()
|
||||
)
|
||||
} else {
|
||||
Log.w(TAG, "[GroupReceipts] Could not find a local recipient for backup recipient ID ${sendStatus.recipientId}! Skipping.")
|
||||
|
||||
Reference in New Issue
Block a user