mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Allow PNI-only contact inserts.
This commit is contained in:
@@ -60,25 +60,6 @@ class RecipientTableTest_getAndPossiblyMerge {
|
||||
FeatureFlagsAccessor.forceValue(FeatureFlags.PHONE_NUMBER_PRIVACY, true)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun single() {
|
||||
test("local user, local e164+aci provided, changeSelf=false, leave pni alone") {
|
||||
given(E164_SELF, PNI_SELF, ACI_SELF)
|
||||
|
||||
process(E164_SELF, PNI_A, ACI_A)
|
||||
|
||||
expect(E164_SELF, PNI_SELF, ACI_SELF)
|
||||
}
|
||||
|
||||
test("local user, local e164+aci provided, changeSelf=false, leave pni alone") {
|
||||
given(E164_SELF, PNI_A, ACI_SELF)
|
||||
|
||||
process(E164_SELF, PNI_SELF, ACI_A)
|
||||
|
||||
expect(E164_SELF, PNI_A, ACI_SELF)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun allNonMergeTests() {
|
||||
test("e164-only insert") {
|
||||
@@ -89,7 +70,7 @@ class RecipientTableTest_getAndPossiblyMerge {
|
||||
assertEquals(RecipientTable.RegisteredState.UNKNOWN, record.registered)
|
||||
}
|
||||
|
||||
test("pni-only insert", exception = IllegalArgumentException::class.java) {
|
||||
test("pni-only insert") {
|
||||
val id = process(null, PNI_A, null)
|
||||
expect(null, PNI_A, null)
|
||||
|
||||
@@ -137,9 +118,9 @@ class RecipientTableTest_getAndPossiblyMerge {
|
||||
expect(E164_A, null, null)
|
||||
}
|
||||
|
||||
test("no match, e164 and pni") {
|
||||
process(E164_A, PNI_A, null)
|
||||
expect(E164_A, PNI_A, null)
|
||||
test("no match, pni-only") {
|
||||
process(null, PNI_A, null)
|
||||
expect(null, PNI_A, null)
|
||||
}
|
||||
|
||||
test("no match, aci-only") {
|
||||
@@ -147,6 +128,11 @@ class RecipientTableTest_getAndPossiblyMerge {
|
||||
expect(null, null, ACI_A)
|
||||
}
|
||||
|
||||
test("no match, e164 and pni") {
|
||||
process(E164_A, PNI_A, null)
|
||||
expect(E164_A, PNI_A, null)
|
||||
}
|
||||
|
||||
test("no match, e164 and aci") {
|
||||
process(E164_A, null, ACI_A)
|
||||
expect(E164_A, null, ACI_A)
|
||||
@@ -713,6 +699,22 @@ class RecipientTableTest_getAndPossiblyMerge {
|
||||
process(E164_A, null, ACI_SELF, changeSelf = true)
|
||||
expect(E164_A, null, ACI_SELF)
|
||||
}
|
||||
|
||||
test("local user, local e164+aci provided, changeSelf=false, leave pni alone") {
|
||||
given(E164_SELF, PNI_SELF, ACI_SELF)
|
||||
|
||||
process(E164_SELF, PNI_A, ACI_A)
|
||||
|
||||
expect(E164_SELF, PNI_SELF, ACI_SELF)
|
||||
}
|
||||
|
||||
test("local user, local e164+aci provided, changeSelf=false, leave pni alone") {
|
||||
given(E164_SELF, PNI_A, ACI_SELF)
|
||||
|
||||
process(E164_SELF, PNI_SELF, ACI_A)
|
||||
|
||||
expect(E164_SELF, PNI_A, ACI_SELF)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -445,7 +445,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
|
||||
@VisibleForTesting
|
||||
fun getAndPossiblyMerge(aci: ACI?, pni: PNI?, e164: String?, pniVerified: Boolean = false, changeSelf: Boolean = false): RecipientId {
|
||||
require(aci != null || e164 != null) { "Must provide an ACI or E164!" }
|
||||
require(aci != null || pni != null || e164 != null) { "Must provide an ACI, PNI, or E164!" }
|
||||
|
||||
val db = writableDatabase
|
||||
var transactionSuccessful = false
|
||||
|
||||
Reference in New Issue
Block a user