diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ArchiveErrorCases.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ArchiveErrorCases.kt index 4dd1f7a70f..5459887501 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ArchiveErrorCases.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/ArchiveErrorCases.kt @@ -103,6 +103,14 @@ object ExportSkips { return log(sentTimestamp, "Profile change from self.") } + fun emptyProfileNameChange(sentTimestamp: Long): String { + return log(sentTimestamp, "Profile name change was empty.") + } + + fun emptyLearnedProfileChange(sentTimestamp: Long): String { + return log(sentTimestamp, "Learned profile update was empty.") + } + private fun log(sentTimestamp: Long, message: String): String { return "[SKIP][$sentTimestamp] $message" } diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt index 33460a363c..3e2b68fde0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/exporters/ChatItemArchiveExporter.kt @@ -14,6 +14,7 @@ import org.signal.core.util.EventTimer import org.signal.core.util.Hex import org.signal.core.util.ParallelEventTimer import org.signal.core.util.concurrent.SignalExecutors +import org.signal.core.util.isNotNullOrBlank import org.signal.core.util.logging.Log import org.signal.core.util.nullIfBlank import org.signal.core.util.nullIfEmpty @@ -578,13 +579,21 @@ private fun BackupMessageRecord.toRemoteProfileChangeUpdate(): ChatUpdateMessage ?: Base64.decodeOrNull(this.body)?.let { ProfileChangeDetails.ADAPTER.decode(it) } return if (profileChangeDetails?.profileNameChange != null) { - if (profileChangeDetails.profileNameChange.previous.isNotEmpty() && profileChangeDetails.profileNameChange.newValue.isNotEmpty()) { + if (profileChangeDetails.profileNameChange.previous.isNotBlank() && profileChangeDetails.profileNameChange.newValue.isNotBlank()) { ChatUpdateMessage(profileChange = ProfileChangeChatUpdate(previousName = profileChangeDetails.profileNameChange.previous, newName = profileChangeDetails.profileNameChange.newValue)) } else { + Log.w(TAG, ExportSkips.emptyProfileNameChange(this.dateSent)) null } } else if (profileChangeDetails?.learnedProfileName != null) { - ChatUpdateMessage(learnedProfileChange = LearnedProfileChatUpdate(e164 = profileChangeDetails.learnedProfileName.e164?.e164ToLong(), username = profileChangeDetails.learnedProfileName.username)) + val e164 = profileChangeDetails.learnedProfileName.e164?.e164ToLong() + val username = profileChangeDetails.learnedProfileName.username + if (e164 != null || username.isNotNullOrBlank()) { + ChatUpdateMessage(learnedProfileChange = LearnedProfileChatUpdate(e164 = e164, username = username)) + } else { + Log.w(TAG, ExportSkips.emptyLearnedProfileChange(this.dateSent)) + null + } } else { null }