kopia lustrzana https://github.com/ryukoposting/Signal-Android
Handle the case where a number changes during a recipient merge.
rodzic
686219d473
commit
42d0d84ae0
|
@ -302,6 +302,28 @@ class RecipientDatabaseTest {
|
||||||
assertEquals(E164_A, existingRecipient2.requireE164())
|
assertEquals(E164_A, existingRecipient2.requireE164())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Another high trust case that results in a merge. Nothing strictly new here, but this case is called out because it’s a merge but *also* an E164 change,
|
||||||
|
* which clients may need to know for UX purposes.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_mergeAndPhoneNumberChange_highTrust() {
|
||||||
|
val existingId1: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, true)
|
||||||
|
val existingId2: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A, true)
|
||||||
|
|
||||||
|
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true)
|
||||||
|
assertEquals(existingId1, retrievedId)
|
||||||
|
|
||||||
|
val retrievedRecipient = Recipient.resolved(retrievedId)
|
||||||
|
assertEquals(ACI_A, retrievedRecipient.requireAci())
|
||||||
|
assertEquals(E164_A, retrievedRecipient.requireE164())
|
||||||
|
|
||||||
|
assertFalse(recipientDatabase.getByE164(E164_B).isPresent)
|
||||||
|
|
||||||
|
val recipientWithId2 = Recipient.resolved(existingId2)
|
||||||
|
assertEquals(retrievedId, recipientWithId2.id)
|
||||||
|
}
|
||||||
|
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
// Misc
|
// Misc
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
|
|
@ -547,6 +547,20 @@ public class RecipientDatabase extends Database {
|
||||||
Log.w(TAG, "The E164 contact has a different ACI. Likely a case of re-registration. Low-trust, so doing nothing.", true);
|
Log.w(TAG, "The E164 contact has a different ACI. Likely a case of re-registration. Low-trust, so doing nothing.", true);
|
||||||
finalId = byAci.get();
|
finalId = byAci.get();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
RecipientSettings aciSettings = getRecipientSettings(byAci.get());
|
||||||
|
|
||||||
|
if (aciSettings.getE164() != null) {
|
||||||
|
if (highTrust) {
|
||||||
|
Log.w(TAG, "We have one contact with just an E164, and another with both an ACI and a different E164. High-trust, so merging the two rows together. The E164 has also effectively changed for the ACI contact.", true);
|
||||||
|
finalId = merge(byAci.get(), byE164.get());
|
||||||
|
recipientNeedingRefresh = byAci.get();
|
||||||
|
remapped = new Pair<>(byE164.get(), byAci.get());
|
||||||
|
recipientChangedNumber = finalId;
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "We have one contact with just an E164, and another with both an ACI and a different E164. Low-trust, so doing nothing.", true);
|
||||||
|
finalId = byAci.get();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (highTrust) {
|
if (highTrust) {
|
||||||
Log.w(TAG, "We have one contact with just an E164, and another with just an ACI. High-trust, so merging the two rows together.", true);
|
Log.w(TAG, "We have one contact with just an E164, and another with just an ACI. High-trust, so merging the two rows together.", true);
|
||||||
|
@ -560,6 +574,7 @@ public class RecipientDatabase extends Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
transactionSuccessful = true;
|
transactionSuccessful = true;
|
||||||
|
|
Ładowanie…
Reference in New Issue