mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-27 05:03:28 +00:00
Handle additional backup transfer to new phone validation errors.
This commit is contained in:
committed by
Greyson Parrelli
parent
77bbc6b5f4
commit
c431ba3f7a
@@ -51,6 +51,10 @@ object ExportSkips {
|
||||
return log(sentTimestamp, "Direct story reply has no body.")
|
||||
}
|
||||
|
||||
fun directStoryReplyInNoteToSelf(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "Direct story reply in Note to Self.")
|
||||
}
|
||||
|
||||
fun invalidChatItemStickerPackId(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "Sticker message had an invalid packId.")
|
||||
}
|
||||
@@ -87,6 +91,18 @@ object ExportSkips {
|
||||
return log(sentTimestamp, "A 1:1 message is located in the wrong chat.")
|
||||
}
|
||||
|
||||
fun paymentNotificationInNoteToSelf(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "Payment notification is in Note to Self.")
|
||||
}
|
||||
|
||||
fun profileChangeInNoteToSelf(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "Profile change in Note to Self.")
|
||||
}
|
||||
|
||||
fun profileChangeFromSelf(sentTimestamp: Long): String {
|
||||
return log(sentTimestamp, "Profile change from self.")
|
||||
}
|
||||
|
||||
private fun log(sentTimestamp: Long, message: String): String {
|
||||
return "[SKIP][$sentTimestamp] $message"
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ fun MessageTable.getMessagesForBackup(db: SignalDatabase, backupTime: Long, medi
|
||||
batchSize = 10_000,
|
||||
mediaArchiveEnabled = mediaBackupEnabled,
|
||||
selfRecipientId = selfRecipientId,
|
||||
noteToSelfThreadId = db.threadTable.getThreadIdFor(selfRecipientId) ?: -1L,
|
||||
exportState = exportState,
|
||||
cursorGenerator = { lastSeenReceivedTime, count ->
|
||||
readableDatabase
|
||||
|
||||
@@ -116,6 +116,7 @@ private val TAG = Log.tag(ChatItemArchiveExporter::class.java)
|
||||
class ChatItemArchiveExporter(
|
||||
private val db: SignalDatabase,
|
||||
private val selfRecipientId: RecipientId,
|
||||
private val noteToSelfThreadId: Long,
|
||||
private val backupStartTime: Long,
|
||||
private val batchSize: Int,
|
||||
private val mediaArchiveEnabled: Boolean,
|
||||
@@ -249,6 +250,16 @@ class ChatItemArchiveExporter(
|
||||
}
|
||||
|
||||
MessageTypes.isProfileChange(record.type) -> {
|
||||
if (record.threadId == noteToSelfThreadId) {
|
||||
Log.w(TAG, ExportSkips.profileChangeInNoteToSelf(record.dateSent))
|
||||
continue
|
||||
}
|
||||
|
||||
if (record.fromRecipientId == selfRecipientId.toLong()) {
|
||||
Log.w(TAG, ExportSkips.profileChangeFromSelf(record.dateSent))
|
||||
continue
|
||||
}
|
||||
|
||||
builder.updateMessage = record.toRemoteProfileChangeUpdate() ?: continue
|
||||
}
|
||||
|
||||
@@ -287,6 +298,10 @@ class ChatItemArchiveExporter(
|
||||
}
|
||||
|
||||
MessageTypes.isPaymentsNotification(record.type) -> {
|
||||
if (record.threadId == noteToSelfThreadId) {
|
||||
Log.w(TAG, ExportSkips.paymentNotificationInNoteToSelf(record.dateSent))
|
||||
continue
|
||||
}
|
||||
builder.paymentNotification = record.toRemotePaymentNotificationUpdate(db)
|
||||
}
|
||||
|
||||
@@ -303,6 +318,10 @@ class ChatItemArchiveExporter(
|
||||
}
|
||||
|
||||
record.parentStoryId != 0L -> {
|
||||
if (record.threadId == noteToSelfThreadId) {
|
||||
Log.w(TAG, ExportSkips.directStoryReplyInNoteToSelf(record.dateSent))
|
||||
continue
|
||||
}
|
||||
builder.directStoryReplyMessage = record.toRemoteDirectStoryReplyMessage(mediaArchiveEnabled = mediaArchiveEnabled, reactionRecords = extraData.reactionsById[id], attachments = extraData.attachmentsById[record.id]) ?: continue
|
||||
}
|
||||
|
||||
@@ -451,6 +470,7 @@ private fun BackupMessageRecord.toBasicChatItemBuilder(selfRecipientId: Recipien
|
||||
MessageTypes.isEndSessionType(record.type) && MessageTypes.isOutgoingMessageType(record.type) -> record.toRecipientId
|
||||
MessageTypes.isExpirationTimerUpdate(record.type) && MessageTypes.isOutgoingMessageType(type) -> selfRecipientId.toLong()
|
||||
MessageTypes.isOutgoingAudioCall(type) || MessageTypes.isOutgoingVideoCall(type) -> selfRecipientId.toLong()
|
||||
MessageTypes.isMessageRequestAccepted(type) -> selfRecipientId.toLong()
|
||||
else -> record.fromRecipientId
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.thoughtcrime.securesms.backup.v2.processor
|
||||
import android.content.Context
|
||||
import okio.ByteString.Companion.EMPTY
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.signal.core.util.isNotNullOrBlank
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
||||
import org.thoughtcrime.securesms.backup.v2.ImportState
|
||||
@@ -68,7 +69,7 @@ object AccountDataArchiveProcessor {
|
||||
familyName = selfRecord.signalProfileName.familyName,
|
||||
avatarUrlPath = selfRecord.signalProfileAvatar ?: "",
|
||||
username = selfRecord.username?.takeIf { it.isNotBlank() },
|
||||
usernameLink = if (signalStore.accountValues.usernameLink != null) {
|
||||
usernameLink = if (selfRecord.username.isNotNullOrBlank() && signalStore.accountValues.usernameLink != null) {
|
||||
AccountData.UsernameLink(
|
||||
entropy = signalStore.accountValues.usernameLink?.entropy?.toByteString() ?: EMPTY,
|
||||
serverId = signalStore.accountValues.usernameLink?.serverId?.toByteArray()?.toByteString() ?: EMPTY,
|
||||
|
||||
Reference in New Issue
Block a user