Fix PNP issue around thread merging.

main
Greyson Parrelli 2022-11-01 20:14:17 -04:00 zatwierdzone przez Cody Henthorne
rodzic 473c8b199e
commit 8ab16164eb
3 zmienionych plików z 6 dodań i 19 usunięć

Wyświetl plik

@ -588,7 +588,7 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
} }
private fun mmsMessage(sender: RecipientId, time: Long = 0, body: String = "", groupId: Optional<GroupId> = Optional.empty()): IncomingMediaMessage { private fun mmsMessage(sender: RecipientId, time: Long = 0, body: String = "", groupId: Optional<GroupId> = Optional.empty()): IncomingMediaMessage {
return IncomingMediaMessage(sender, groupId, body, time, time, time, emptyList(), 0, 0, false, false, true, Optional.empty()) return IncomingMediaMessage(sender, groupId, body, time, time, time, emptyList(), 0, 0, false, false, true, Optional.empty(), false, false)
} }
private fun identityKey(value: Byte): IdentityKey { private fun identityKey(value: Byte): IdentityKey {

Wyświetl plik

@ -30,7 +30,7 @@ data class PnpDataSet(
fun MutableSet<RecipientRecord>.replace(recipientId: RecipientId, update: (RecipientRecord) -> RecipientRecord) { fun MutableSet<RecipientRecord>.replace(recipientId: RecipientId, update: (RecipientRecord) -> RecipientRecord) {
val toUpdate = this.first { it.id == recipientId } val toUpdate = this.first { it.id == recipientId }
this -= toUpdate this.removeIf { it.id == toUpdate.id }
this += update(toUpdate) this += update(toUpdate)
} }
/** /**
@ -92,7 +92,7 @@ data class PnpDataSet(
) )
} }
records -= secondary records.removeIf { it.id == secondary.id }
} }
is PnpOperation.SessionSwitchoverInsert -> Unit is PnpOperation.SessionSwitchoverInsert -> Unit
is PnpOperation.ChangeNumberInsert -> Unit is PnpOperation.ChangeNumberInsert -> Unit

Wyświetl plik

@ -2466,7 +2466,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
changeSet.id.recipientId changeSet.id.recipientId
} }
is PnpIdResolver.PnpInsert -> { is PnpIdResolver.PnpInsert -> {
val id: Long = writableDatabase.insert(TABLE_NAME, null, buildContentValuesForPnpInsert(changeSet.id.e164, changeSet.id.pni, changeSet.id.aci)) val id: Long = writableDatabase.insert(TABLE_NAME, null, buildContentValuesForNewUser(changeSet.id.e164, changeSet.id.pni, changeSet.id.aci))
RecipientId.from(id) RecipientId.from(id)
} }
} }
@ -3632,20 +3632,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
check(writableDatabase.inTransaction()) { "Must be in a transaction!" } check(writableDatabase.inTransaction()) { "Must be in a transaction!" }
} }
private fun buildContentValuesForNewUser(e164: String?, serviceId: ServiceId?): ContentValues { private fun buildContentValuesForNewUser(e164: String?, pni: PNI?, aci: ACI?): ContentValues {
val values = ContentValues()
values.put(PHONE, e164)
if (serviceId != null) {
values.put(SERVICE_ID, serviceId.toString().lowercase())
values.put(REGISTERED, RegisteredState.REGISTERED.id)
values.put(UNREGISTERED_TIMESTAMP, 0)
values.put(STORAGE_SERVICE_ID, Base64.encodeBytes(StorageSyncHelper.generateKey()))
values.put(AVATAR_COLOR, AvatarColor.random().serialize())
}
return values
}
private fun buildContentValuesForPnpInsert(e164: String?, pni: PNI?, aci: ACI?): ContentValues {
check(e164 != null || pni != null || aci != null) { "Must provide some sort of identifier!" } check(e164 != null || pni != null || aci != null) { "Must provide some sort of identifier!" }
val values = contentValuesOf( val values = contentValuesOf(
@ -3675,7 +3662,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
} }
if (FeatureFlags.phoneNumberPrivacy()) { if (FeatureFlags.phoneNumberPrivacy()) {
put(PNI_COLUMN, contact.pni.toString()) put(PNI_COLUMN, contact.pni.orElse(null)?.toString())
} }
put(PHONE, contact.number.orElse(null)) put(PHONE, contact.number.orElse(null))