kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix PNP issue around thread merging.
rodzic
473c8b199e
commit
8ab16164eb
|
@ -588,7 +588,7 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -30,7 +30,7 @@ data class PnpDataSet(
|
|||
|
||||
fun MutableSet<RecipientRecord>.replace(recipientId: RecipientId, update: (RecipientRecord) -> RecipientRecord) {
|
||||
val toUpdate = this.first { it.id == recipientId }
|
||||
this -= toUpdate
|
||||
this.removeIf { it.id == toUpdate.id }
|
||||
this += update(toUpdate)
|
||||
}
|
||||
/**
|
||||
|
@ -92,7 +92,7 @@ data class PnpDataSet(
|
|||
)
|
||||
}
|
||||
|
||||
records -= secondary
|
||||
records.removeIf { it.id == secondary.id }
|
||||
}
|
||||
is PnpOperation.SessionSwitchoverInsert -> Unit
|
||||
is PnpOperation.ChangeNumberInsert -> Unit
|
||||
|
|
|
@ -2466,7 +2466,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
|||
changeSet.id.recipientId
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -3632,20 +3632,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
|||
check(writableDatabase.inTransaction()) { "Must be in a transaction!" }
|
||||
}
|
||||
|
||||
private fun buildContentValuesForNewUser(e164: String?, serviceId: ServiceId?): 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 {
|
||||
private fun buildContentValuesForNewUser(e164: String?, pni: PNI?, aci: ACI?): ContentValues {
|
||||
check(e164 != null || pni != null || aci != null) { "Must provide some sort of identifier!" }
|
||||
|
||||
val values = contentValuesOf(
|
||||
|
@ -3675,7 +3662,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
|
|||
}
|
||||
|
||||
if (FeatureFlags.phoneNumberPrivacy()) {
|
||||
put(PNI_COLUMN, contact.pni.toString())
|
||||
put(PNI_COLUMN, contact.pni.orElse(null)?.toString())
|
||||
}
|
||||
|
||||
put(PHONE, contact.number.orElse(null))
|
||||
|
|
Ładowanie…
Reference in New Issue