mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Fix potential archive export issue around voice notes in revisions.
This commit is contained in:
@@ -1475,10 +1475,14 @@ fun ChatItem.validateChatItem(): ChatItem? {
|
|||||||
|
|
||||||
fun List<ChatItem>.repairRevisions(current: ChatItem.Builder): List<ChatItem> {
|
fun List<ChatItem>.repairRevisions(current: ChatItem.Builder): List<ChatItem> {
|
||||||
return if (current.standardMessage != null) {
|
return if (current.standardMessage != null) {
|
||||||
val filtered = this.filter { it.standardMessage != null }
|
val filtered = this
|
||||||
|
.filter { it.standardMessage != null }
|
||||||
|
.map { it.withDowngradeVoiceNotes() }
|
||||||
|
|
||||||
if (this.size != filtered.size) {
|
if (this.size != filtered.size) {
|
||||||
Log.w(TAG, ExportOddities.mismatchedRevisionHistory(current.dateSent))
|
Log.w(TAG, ExportOddities.mismatchedRevisionHistory(current.dateSent))
|
||||||
}
|
}
|
||||||
|
|
||||||
filtered
|
filtered
|
||||||
} else if (current.directStoryReplyMessage != null) {
|
} else if (current.directStoryReplyMessage != null) {
|
||||||
val filtered = this.filter { it.directStoryReplyMessage != null }
|
val filtered = this.filter { it.directStoryReplyMessage != null }
|
||||||
@@ -1506,6 +1510,28 @@ private fun List<MessageAttachment>.withFixedVoiceNotes(textPresent: Boolean): L
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun ChatItem.withDowngradeVoiceNotes(): ChatItem {
|
||||||
|
if (this.standardMessage == null) {
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.standardMessage.attachments.none { it.flag == MessageAttachment.Flag.VOICE_MESSAGE }) {
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.copy(
|
||||||
|
standardMessage = this.standardMessage.copy(
|
||||||
|
attachments = this.standardMessage.attachments.map {
|
||||||
|
if (it.flag == MessageAttachment.Flag.VOICE_MESSAGE) {
|
||||||
|
it.copy(flag = MessageAttachment.Flag.NONE)
|
||||||
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun Cursor.toBackupMessageRecord(pastIds: Set<Long>, backupStartTime: Long): BackupMessageRecord? {
|
private fun Cursor.toBackupMessageRecord(pastIds: Set<Long>, backupStartTime: Long): BackupMessageRecord? {
|
||||||
val id = this.requireLong(MessageTable.ID)
|
val id = this.requireLong(MessageTable.ID)
|
||||||
if (pastIds.contains(id)) {
|
if (pastIds.contains(id)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user