Filter out revisions with mismatched authors during backup export.

This commit is contained in:
Greyson Parrelli
2026-03-24 15:46:39 +00:00
committed by Alex Hart
parent 72d75e9cd5
commit 3d2c51c14b
2 changed files with 13 additions and 4 deletions

View File

@@ -194,6 +194,10 @@ object ExportOddities {
return log(sentTimestamp, "Revisions for this message contained items of a different type than the parent item. Ignoring mismatched revisions.")
}
fun mismatchedRevisionAuthor(sentTimestamp: Long): String {
return log(sentTimestamp, "Revisions for this message contained items with a different author than the parent item. Ignoring mismatched revisions.")
}
fun outgoingMessageWasSentButTimerNotStarted(sentTimestamp: Long): String {
return log(sentTimestamp, "Outgoing expiring message was sent, but the timer wasn't started. Setting expireStartDate to dateReceived.")
}

View File

@@ -1741,19 +1741,24 @@ private fun ChatUpdateMessage.canOnlyBeAuthoredBySelf(): Boolean {
}
private fun List<ChatItem>.repairRevisions(current: ChatItem.Builder): List<ChatItem> {
val authorFiltered = this.filter { it.authorId == current.authorId }
if (authorFiltered.size != this.size) {
Log.w(TAG, ExportOddities.mismatchedRevisionAuthor(current.dateSent))
}
return if (current.standardMessage != null) {
val filtered = this
val filtered = authorFiltered
.filter { it.standardMessage != null }
.map { it.withDowngradeVoiceNotes() }
if (this.size != filtered.size) {
if (authorFiltered.size != filtered.size) {
Log.w(TAG, ExportOddities.mismatchedRevisionHistory(current.dateSent))
}
filtered
} else if (current.directStoryReplyMessage != null) {
val filtered = this.filter { it.directStoryReplyMessage != null }
if (this.size != filtered.size) {
val filtered = authorFiltered.filter { it.directStoryReplyMessage != null }
if (authorFiltered.size != filtered.size) {
Log.w(TAG, ExportOddities.mismatchedRevisionHistory(current.dateSent))
}
filtered