Skip to content

Commit 908a418

Browse files
authored
correct some theoretical bugs in unresolved service ID collection
1 parent 3ae145b commit 908a418

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import java.util.concurrent.CancellationException;
6060
import java.util.concurrent.CompletableFuture;
6161
import java.util.concurrent.ExecutionException;
62+
import java.util.function.Predicate;
6263
import java.util.stream.Collectors;
6364
import java.util.stream.Stream;
6465
import javax.annotation.Nullable;
@@ -684,16 +685,21 @@ public Response sendMultiRecipientMessage(
684685
messageSender.sendMultiRecipientMessage(multiRecipientMessage, resolvedRecipients, timestamp, isStory, online, isUrgent).get();
685686
}
686687

687-
final List<ServiceIdentifier> unresolvedRecipientServiceIds = authType == AUTH_TYPE_GROUP_SEND_TOKEN ? new ArrayList<>() : List.of();
688+
final List<ServiceIdentifier> unresolvedRecipientServiceIds;
689+
if (AUTH_TYPE_GROUP_SEND_TOKEN.equals(authType)) {
690+
unresolvedRecipientServiceIds = multiRecipientMessage.getRecipients().entrySet().stream()
691+
.filter(entry -> !resolvedRecipients.containsKey(entry.getValue()))
692+
.map(entry -> ServiceIdentifier.fromLibsignal(entry.getKey()))
693+
.toList();
694+
} else {
695+
unresolvedRecipientServiceIds = List.of();
696+
}
688697

689698
multiRecipientMessage.getRecipients().forEach((serviceId, recipient) -> {
690699
if (!resolvedRecipients.containsKey(recipient)) {
691700
// We skipped sending to this recipient because we couldn't resolve the recipient to an
692701
// existing account; don't increment the counter for this recipient. If the client was
693702
// using a GSE, track the missing recipients to include in the response.
694-
if (authType == AUTH_TYPE_GROUP_SEND_TOKEN) {
695-
unresolvedRecipientServiceIds.add(ServiceIdentifier.fromLibsignal(serviceId));
696-
}
697703
return;
698704
}
699705

0 commit comments

Comments
 (0)