mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-25 05:27:42 +00:00
Add backup support for direct story reply revisions.
This commit is contained in:
@@ -58,8 +58,12 @@ object ExportSkips {
|
||||
*/
|
||||
object ExportOddities {
|
||||
|
||||
fun revisionsOnNonStandardMessage(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "Attempted to set revisions on a non-standard message. Ignoring revisions.")
|
||||
fun revisionsOnUnexpectedMessageType(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "Attempted to set revisions on message that doesn't support it. Ignoring revisions.")
|
||||
}
|
||||
|
||||
fun mismatchedRevisionHistory(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "Revisions for this message contained items of a different type than the parent item. Ignoring mismatched revisions.")
|
||||
}
|
||||
|
||||
fun outgoingMessageWasSentButTimerNotStarted(sentTimestamp: Long): String {
|
||||
|
||||
@@ -325,14 +325,7 @@ class ChatItemArchiveExporter(
|
||||
}
|
||||
|
||||
if (record.latestRevisionId == null) {
|
||||
val previousEdits = revisionMap.remove(record.id)
|
||||
if (previousEdits != null) {
|
||||
if (builder.standardMessage != null) {
|
||||
builder.revisions = previousEdits
|
||||
} else {
|
||||
Log.w(TAG, ExportOddities.revisionsOnNonStandardMessage(record.dateSent))
|
||||
}
|
||||
}
|
||||
builder.revisions = revisionMap.remove(record.id)?.repairRevisions(builder) ?: emptyList()
|
||||
buffer += builder.build()
|
||||
} else {
|
||||
var previousEdits = revisionMap[record.latestRevisionId]
|
||||
@@ -1331,6 +1324,25 @@ private fun <T> ExecutorService.submitTyped(callable: Callable<T>): Future<T> {
|
||||
return this.submit(callable)
|
||||
}
|
||||
|
||||
fun List<ChatItem>.repairRevisions(current: ChatItem.Builder): List<ChatItem> {
|
||||
return if (current.standardMessage != null) {
|
||||
val filtered = this.filter { it.standardMessage != null }
|
||||
if (this.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) {
|
||||
Log.w(TAG, ExportOddities.mismatchedRevisionHistory(current.dateSent))
|
||||
}
|
||||
filtered
|
||||
} else {
|
||||
Log.w(TAG, ExportOddities.revisionsOnUnexpectedMessageType(current.dateSent))
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun Cursor.toBackupMessageRecord(pastIds: Set<Long>, backupStartTime: Long): BackupMessageRecord? {
|
||||
val id = this.requireLong(MessageTable.ID)
|
||||
if (pastIds.contains(id)) {
|
||||
|
||||
Reference in New Issue
Block a user