mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Add backup support for direct story reply revisions.
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -81,6 +81,11 @@ class ArchiveImportExportTests {
|
|||||||
runTests { it.startsWith("chat_item_direct_story_reply_") }
|
runTests { it.startsWith("chat_item_direct_story_reply_") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
fun chatItemDirectStoryReplyMessageWithEdits() {
|
||||||
|
runTests { it.startsWith("chat_item_direct_story_reply_with_edits_") }
|
||||||
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
fun chatItemExpirationTimerUpdate() {
|
fun chatItemExpirationTimerUpdate() {
|
||||||
runTests { it.startsWith("chat_item_expiration_timer_update_") }
|
runTests { it.startsWith("chat_item_expiration_timer_update_") }
|
||||||
|
|||||||
@@ -58,8 +58,12 @@ object ExportSkips {
|
|||||||
*/
|
*/
|
||||||
object ExportOddities {
|
object ExportOddities {
|
||||||
|
|
||||||
fun revisionsOnNonStandardMessage(sentTimestamp: Long): String {
|
fun revisionsOnUnexpectedMessageType(sentTimestamp: Long): String {
|
||||||
return log(sentTimestamp, "Attempted to set revisions on a non-standard message. Ignoring revisions.")
|
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 {
|
fun outgoingMessageWasSentButTimerNotStarted(sentTimestamp: Long): String {
|
||||||
|
|||||||
@@ -325,14 +325,7 @@ class ChatItemArchiveExporter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (record.latestRevisionId == null) {
|
if (record.latestRevisionId == null) {
|
||||||
val previousEdits = revisionMap.remove(record.id)
|
builder.revisions = revisionMap.remove(record.id)?.repairRevisions(builder) ?: emptyList()
|
||||||
if (previousEdits != null) {
|
|
||||||
if (builder.standardMessage != null) {
|
|
||||||
builder.revisions = previousEdits
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, ExportOddities.revisionsOnNonStandardMessage(record.dateSent))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buffer += builder.build()
|
buffer += builder.build()
|
||||||
} else {
|
} else {
|
||||||
var previousEdits = revisionMap[record.latestRevisionId]
|
var previousEdits = revisionMap[record.latestRevisionId]
|
||||||
@@ -1331,6 +1324,25 @@ private fun <T> ExecutorService.submitTyped(callable: Callable<T>): Future<T> {
|
|||||||
return this.submit(callable)
|
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? {
|
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