Update a specific recipient case to merge rather than just steal PNI.

This commit is contained in:
Greyson Parrelli 2024-02-23 14:57:38 -05:00
parent dcd0d433b0
commit 43caaf7efc
2 changed files with 15 additions and 4 deletions

View file

@ -788,6 +788,17 @@ class RecipientTableTest_getAndPossiblyMerge {
expectChangeNumberEvent()
}
test("merge, e164 follows pni+aci") {
given(E164_A, PNI_A, null)
given(null, null, ACI_A)
process(null, PNI_A, ACI_A, pniVerified = true)
expect(E164_A, PNI_A, ACI_A)
expectThreadMergeEvent(E164_A)
expectPniVerified()
}
test("local user, local e164 and aci provided, changeSelf=false, leave e164 alone") {
given(E164_SELF, null, ACI_SELF)
given(null, null, ACI_A)

View file

@ -2944,10 +2944,10 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
primaryId = data.byAci,
secondaryId = data.byPni
)
} else if (data.pniRecord.aci == null && data.pniRecord.e164 == data.e164) {
} else if (data.pniRecord.aci == null && (data.e164 == null || data.pniRecord.e164 == data.e164)) {
// The PNI record also has the E164 on it with no ACI. We're going to be stealing all of it's fields,
// so this is basically a merge with a little bit of extra prep.
breadCrumbs += "PniRecordHasMatchingE164AndNoAci"
breadCrumbs += "PniRecordHasNoAci"
if (data.aciRecord.pni != null) {
operations += PnpOperation.RemovePni(data.byAci)
@ -2972,10 +2972,10 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
secondaryId = data.byPni
)
} else {
// The PNI record either has an ACI or a non-matching e164, meaning we need to steal what we need and leave the rest behind
// The PNI record has a different ACI, meaning we need to steal what we need and leave the rest behind
breadCrumbs += if (data.pniRecord.aci != null && data.pniRecord.e164 != data.e164) {
"PniRecordHasAciAndNonMatchingE164"
"PniRecordHasAci"
} else if (data.pniRecord.aci != null) {
"PniRecordHasAci"
} else {