mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +00:00
Ensure numbers are properly formatted before giving them to contact discovery service.
We were sending "Unknown" addresses, which would cause the service to choke.
This commit is contained in:
parent
946f76a442
commit
6359961a82
@ -348,8 +348,9 @@ public class DirectoryHelper {
|
||||
@NonNull SignalServiceAccountManager accountManager,
|
||||
@NonNull Set<String> eligibleContactNumbers)
|
||||
{
|
||||
List<Set<String>> batches = splitIntoBatches(eligibleContactNumbers, CONTACT_DISCOVERY_BATCH_SIZE);
|
||||
List<Future<Set<String>>> futures = new ArrayList<>(batches.size());
|
||||
Set<String> sanitizedNumbers = sanitizeNumbers(eligibleContactNumbers);
|
||||
List<Set<String>> batches = splitIntoBatches(sanitizedNumbers, CONTACT_DISCOVERY_BATCH_SIZE);
|
||||
List<Future<Set<String>>> futures = new ArrayList<>(batches.size());
|
||||
|
||||
for (Set<String> batch : batches) {
|
||||
Future<Set<String>> future = SignalExecutors.IO.submit(() -> {
|
||||
@ -360,6 +361,10 @@ public class DirectoryHelper {
|
||||
return futures;
|
||||
}
|
||||
|
||||
private static Set<String> sanitizeNumbers(@NonNull Set<String> numbers) {
|
||||
return Stream.of(numbers).filter(number -> number.startsWith("+")).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private static List<Set<String>> splitIntoBatches(@NonNull Set<String> numbers, int batchSize) {
|
||||
List<String> numberList = new ArrayList<>(numbers);
|
||||
List<Set<String>> batches = new LinkedList<>();
|
||||
|
Loading…
Reference in New Issue
Block a user