Do not export blank profile name changes.

This commit is contained in:
Greyson Parrelli
2025-01-30 15:46:55 -05:00
parent e3b1ef7904
commit 8962b67e33
2 changed files with 19 additions and 2 deletions

View File

@@ -103,6 +103,14 @@ object ExportSkips {
return log(sentTimestamp, "Profile change from self.") 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 { private fun log(sentTimestamp: Long, message: String): String {
return "[SKIP][$sentTimestamp] $message" return "[SKIP][$sentTimestamp] $message"
} }

View File

@@ -14,6 +14,7 @@ import org.signal.core.util.EventTimer
import org.signal.core.util.Hex import org.signal.core.util.Hex
import org.signal.core.util.ParallelEventTimer import org.signal.core.util.ParallelEventTimer
import org.signal.core.util.concurrent.SignalExecutors 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.logging.Log
import org.signal.core.util.nullIfBlank import org.signal.core.util.nullIfBlank
import org.signal.core.util.nullIfEmpty import org.signal.core.util.nullIfEmpty
@@ -578,13 +579,21 @@ private fun BackupMessageRecord.toRemoteProfileChangeUpdate(): ChatUpdateMessage
?: Base64.decodeOrNull(this.body)?.let { ProfileChangeDetails.ADAPTER.decode(it) } ?: Base64.decodeOrNull(this.body)?.let { ProfileChangeDetails.ADAPTER.decode(it) }
return if (profileChangeDetails?.profileNameChange != null) { 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)) ChatUpdateMessage(profileChange = ProfileChangeChatUpdate(previousName = profileChangeDetails.profileNameChange.previous, newName = profileChangeDetails.profileNameChange.newValue))
} else { } else {
Log.w(TAG, ExportSkips.emptyProfileNameChange(this.dateSent))
null null
} }
} else if (profileChangeDetails?.learnedProfileName != 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 { } else {
null null
} }