mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Remove concept of V1 vs V2 fuzzy phone number results.
V1 hasn't been used in a long time. So we can just delete that code then remove the concept of a 'v2' from the other stuff.
This commit is contained in:
@@ -66,8 +66,8 @@ class ContactDiscoveryV2 {
|
||||
KeyStore iasKeyStore = getIasKeyStore(context);
|
||||
|
||||
try {
|
||||
Map<String, UUID> results = accountManager.getRegisteredUsers(iasKeyStore, sanitizedNumbers, BuildConfig.CDS_MRENCLAVE);
|
||||
FuzzyPhoneNumberHelper.OutputResultV2 outputResult = FuzzyPhoneNumberHelper.generateOutputV2(results, inputResult);
|
||||
Map<String, UUID> results = accountManager.getRegisteredUsers(iasKeyStore, sanitizedNumbers, BuildConfig.CDS_MRENCLAVE);
|
||||
FuzzyPhoneNumberHelper.OutputResult outputResult = FuzzyPhoneNumberHelper.generateOutput(results, inputResult);
|
||||
|
||||
return new DirectoryResult(outputResult.getNumbers(), outputResult.getRewrites(), ignoredNumbers);
|
||||
} catch (SignatureException | UnauthenticatedQuoteException | UnauthenticatedResponseException | Quote.InvalidQuoteFormatException |InvalidKeyException e) {
|
||||
|
||||
@@ -46,8 +46,8 @@ class ContactDiscoveryV3 {
|
||||
SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager();
|
||||
|
||||
try {
|
||||
Map<String, UUID> results = accountManager.getRegisteredUsersWithCdsh(sanitizedNumbers, BuildConfig.CDSH_PUBLIC_KEY, BuildConfig.CDSH_CODE_HASH);
|
||||
FuzzyPhoneNumberHelper.OutputResultV2 outputResult = FuzzyPhoneNumberHelper.generateOutputV2(results, inputResult);
|
||||
Map<String, UUID> results = accountManager.getRegisteredUsersWithCdsh(sanitizedNumbers, BuildConfig.CDSH_PUBLIC_KEY, BuildConfig.CDSH_CODE_HASH);
|
||||
FuzzyPhoneNumberHelper.OutputResult outputResult = FuzzyPhoneNumberHelper.generateOutput(results, inputResult);
|
||||
|
||||
return new DirectoryResult(outputResult.getNumbers(), outputResult.getRewrites(), ignoredNumbers);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -30,7 +30,6 @@ class FuzzyPhoneNumberHelper {
|
||||
Set<String> allNumbers = new HashSet<>(testNumbers);
|
||||
Map<String, String> fuzzies = new HashMap<>();
|
||||
|
||||
|
||||
for (String number : testNumbers) {
|
||||
for (FuzzyVariant fuzzyVariant: FUZZY_VARIANTS) {
|
||||
if(fuzzyVariant.hasVariants(number)) {
|
||||
@@ -50,37 +49,7 @@ class FuzzyPhoneNumberHelper {
|
||||
* these results and our initial input set, we can decide if we need to rewrite which number we
|
||||
* have stored locally.
|
||||
*/
|
||||
static @NonNull OutputResult generateOutput(@NonNull Collection<String> registeredNumbers, @NonNull InputResult inputResult) {
|
||||
Set<String> allNumbers = new HashSet<>(registeredNumbers);
|
||||
Map<String, String> rewrites = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : inputResult.getFuzzies().entrySet()) {
|
||||
if (registeredNumbers.contains(entry.getKey()) && registeredNumbers.contains(entry.getValue())) {
|
||||
for (FuzzyVariant fuzzyVariant: FUZZY_VARIANTS) {
|
||||
if(fuzzyVariant.hasVariants(entry.getKey())) {
|
||||
if (fuzzyVariant.isDefaultVariant(entry.getKey())) {
|
||||
allNumbers.remove(entry.getValue());
|
||||
} else {
|
||||
rewrites.put(entry.getKey(), entry.getValue());
|
||||
allNumbers.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (registeredNumbers.contains(entry.getValue())) {
|
||||
rewrites.put(entry.getKey(), entry.getValue());
|
||||
allNumbers.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
return new OutputResult(allNumbers, rewrites);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be run on the list of numbers we find out are registered with the server. Based on
|
||||
* these results and our initial input set, we can decide if we need to rewrite which number we
|
||||
* have stored locally.
|
||||
*/
|
||||
static @NonNull OutputResultV2 generateOutputV2(@NonNull Map<String, UUID> registeredNumbers, @NonNull InputResult inputResult) {
|
||||
static @NonNull OutputResult generateOutput(@NonNull Map<String, UUID> registeredNumbers, @NonNull InputResult inputResult) {
|
||||
Map<String, UUID> allNumbers = new HashMap<>(registeredNumbers);
|
||||
Map<String, String> rewrites = new HashMap<>();
|
||||
|
||||
@@ -102,7 +71,7 @@ class FuzzyPhoneNumberHelper {
|
||||
}
|
||||
}
|
||||
|
||||
return new OutputResultV2(allNumbers, rewrites);
|
||||
return new OutputResult(allNumbers, rewrites);
|
||||
}
|
||||
|
||||
private interface FuzzyVariant {
|
||||
@@ -183,28 +152,10 @@ class FuzzyPhoneNumberHelper {
|
||||
}
|
||||
|
||||
public static class OutputResult {
|
||||
private final Set<String> numbers;
|
||||
private final Map<String, String> rewrites;
|
||||
|
||||
private OutputResult(@NonNull Set<String> numbers, @NonNull Map<String, String> rewrites) {
|
||||
this.numbers = numbers;
|
||||
this.rewrites = rewrites;
|
||||
}
|
||||
|
||||
public @NonNull Set<String> getNumbers() {
|
||||
return numbers;
|
||||
}
|
||||
|
||||
public @NonNull Map<String, String> getRewrites() {
|
||||
return rewrites;
|
||||
}
|
||||
}
|
||||
|
||||
public static class OutputResultV2 {
|
||||
private final Map<String, UUID> numbers;
|
||||
private final Map<String, String> rewrites;
|
||||
|
||||
private OutputResultV2(@NonNull Map<String, UUID> numbers, @NonNull Map<String, String> rewrites) {
|
||||
private OutputResult(@NonNull Map<String, UUID> numbers, @NonNull Map<String, String> rewrites) {
|
||||
this.numbers = numbers;
|
||||
this.rewrites = rewrites;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user