Fix linked device nickname change not syncing bug.

This commit is contained in:
Cody Henthorne
2024-04-01 19:06:08 -04:00
committed by GitHub
parent a8f925def0
commit fcdcb9fd33
2 changed files with 37 additions and 0 deletions

View File

@@ -4022,6 +4022,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
val profileName = ProfileName.fromParts(contact.profileGivenName.orElse(null), contact.profileFamilyName.orElse(null))
val systemName = ProfileName.fromParts(contact.systemGivenName.orElse(null), contact.systemFamilyName.orElse(null))
val username = contact.username.orElse(null)
val nickname = ProfileName.fromParts(contact.nicknameGivenName.orNull(), contact.nicknameFamilyName.orNull())
put(ACI_COLUMN, contact.aci.orElse(null)?.toString())
put(PNI_COLUMN, contact.pni.orElse(null)?.toString())
@@ -4041,6 +4042,10 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
put(STORAGE_SERVICE_ID, Base64.encodeWithPadding(contact.id.raw))
put(HIDDEN, contact.isHidden)
put(PNI_SIGNATURE_VERIFIED, contact.isPniSignatureVerified.toInt())
put(NICKNAME_GIVEN_NAME, nickname.givenName.nullIfBlank())
put(NICKNAME_FAMILY_NAME, nickname.familyName.nullIfBlank())
put(NICKNAME_JOINED_NAME, nickname.toString().nullIfBlank())
put(NOTE, contact.note.orNull().nullIfBlank())
if (contact.hasUnknownFields()) {
put(STORAGE_SERVICE_PROTO, Base64.encodeWithPadding(Objects.requireNonNull(contact.serializeUnknownFields())))

View File

@@ -374,6 +374,38 @@ class ContactRecordProcessorTest {
assertEquals(remote.pni.get(), result.pni.get())
}
@Test
fun `merge, nickname change, useRemote`() {
// GIVEN
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
val local = buildRecord(
STORAGE_ID_A,
record = ContactRecord(
aci = ACI_A.toString(),
e164 = E164_A
)
)
val remote = buildRecord(
STORAGE_ID_B,
record = ContactRecord(
aci = ACI_A.toString(),
e164 = E164_A,
nickname = ContactRecord.Name(given = "Ghost", family = "Spider"),
note = "Spidey Friend"
)
)
// WHEN
val result = subject.merge(remote, local, TestKeyGenerator(STORAGE_ID_C))
// THEN
assertEquals("Ghost", result.nicknameGivenName.get())
assertEquals("Spider", result.nicknameFamilyName.get())
assertEquals("Spidey Friend", result.note.get())
}
private fun buildRecord(id: StorageId = STORAGE_ID_A, record: ContactRecord): SignalContactRecord {
return SignalContactRecord(id, record)
}