diff --git a/src/org/thoughtcrime/securesms/util/DirectoryHelper.java b/src/org/thoughtcrime/securesms/util/DirectoryHelper.java index fed2f4e49c..145ec5428f 100644 --- a/src/org/thoughtcrime/securesms/util/DirectoryHelper.java +++ b/src/org/thoughtcrime/securesms/util/DirectoryHelper.java @@ -348,8 +348,9 @@ public class DirectoryHelper { @NonNull SignalServiceAccountManager accountManager, @NonNull Set eligibleContactNumbers) { - List> batches = splitIntoBatches(eligibleContactNumbers, CONTACT_DISCOVERY_BATCH_SIZE); - List>> futures = new ArrayList<>(batches.size()); + Set sanitizedNumbers = sanitizeNumbers(eligibleContactNumbers); + List> batches = splitIntoBatches(sanitizedNumbers, CONTACT_DISCOVERY_BATCH_SIZE); + List>> futures = new ArrayList<>(batches.size()); for (Set batch : batches) { Future> future = SignalExecutors.IO.submit(() -> { @@ -360,6 +361,10 @@ public class DirectoryHelper { return futures; } + private static Set sanitizeNumbers(@NonNull Set numbers) { + return Stream.of(numbers).filter(number -> number.startsWith("+")).collect(Collectors.toSet()); + } + private static List> splitIntoBatches(@NonNull Set numbers, int batchSize) { List numberList = new ArrayList<>(numbers); List> batches = new LinkedList<>();