mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Fix recipient merging case that causes a change number event.
This commit is contained in:
committed by
Alex Hart
parent
10364e9342
commit
b4ced5278e
@@ -776,6 +776,18 @@ class RecipientTableTest_getAndPossiblyMerge {
|
||||
expectThreadMergeEvent(E164_A)
|
||||
}
|
||||
|
||||
test("merge, e164+pni & e164+aci, pni+aci provided, change number") {
|
||||
given(E164_A, PNI_A, null)
|
||||
given(E164_B, null, ACI_A)
|
||||
|
||||
process(null, PNI_A, ACI_A)
|
||||
|
||||
expect(E164_A, PNI_A, ACI_A)
|
||||
|
||||
expectThreadMergeEvent(E164_A)
|
||||
expectChangeNumberEvent()
|
||||
}
|
||||
|
||||
test("merge, e164 + pni reassigned, aci abandoned") {
|
||||
given(E164_A, PNI_A, ACI_A)
|
||||
given(E164_B, PNI_B, ACI_B)
|
||||
|
||||
@@ -2953,7 +2953,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
secondaryId = data.byPni
|
||||
)
|
||||
} 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,
|
||||
// The PNI has no ACI and possibly some e164. 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 += "PniRecordHasNoAci"
|
||||
|
||||
@@ -2961,7 +2961,9 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
operations += PnpOperation.RemovePni(data.byAci)
|
||||
}
|
||||
|
||||
if (data.aciRecord.e164 != null && data.aciRecord.e164 != data.e164) {
|
||||
val newE164 = data.pniRecord.e164 ?: data.e164
|
||||
|
||||
if (data.aciRecord.e164 != null && data.aciRecord.e164 != newE164 && newE164 != null) {
|
||||
operations += PnpOperation.RemoveE164(data.byAci)
|
||||
|
||||
// This also becomes a change number event
|
||||
@@ -2970,7 +2972,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
operations += PnpOperation.ChangeNumberInsert(
|
||||
recipientId = data.byAci,
|
||||
oldE164 = data.aciRecord.e164,
|
||||
newE164 = data.e164!!
|
||||
newE164 = newE164
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user