import org.asamk.signal.manager.api.SendMessageResults;
import org.asamk.signal.manager.api.TypingAction;
import org.asamk.signal.manager.api.UpdateGroup;
-import org.asamk.signal.manager.config.ServiceConfig;
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
import org.asamk.signal.manager.groups.GroupId;
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
import org.asamk.signal.manager.helper.PinHelper;
import org.asamk.signal.manager.helper.PreKeyHelper;
import org.asamk.signal.manager.helper.ProfileHelper;
+import org.asamk.signal.manager.helper.RecipientHelper;
import org.asamk.signal.manager.helper.SendHelper;
import org.asamk.signal.manager.helper.StorageHelper;
import org.asamk.signal.manager.helper.SyncHelper;
import org.whispersystems.signalservice.api.push.ACI;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
-import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
import org.whispersystems.signalservice.api.websocket.WebSocketConnectionState;
import org.whispersystems.signalservice.api.websocket.WebSocketUnavailableException;
-import org.whispersystems.signalservice.internal.contacts.crypto.Quote;
-import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedQuoteException;
-import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
import org.whispersystems.signalservice.internal.util.DynamicCredentialsProvider;
import org.whispersystems.signalservice.internal.util.Hex;
import org.whispersystems.signalservice.internal.util.Util;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
-import java.security.SignatureException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
private final static Logger logger = LoggerFactory.getLogger(ManagerImpl.class);
- private final ServiceEnvironmentConfig serviceEnvironmentConfig;
private final SignalDependencies dependencies;
private SignalAccount account;
private final IncomingMessageHandler incomingMessageHandler;
private final PreKeyHelper preKeyHelper;
private final IdentityHelper identityHelper;
+ private final RecipientHelper recipientHelper;
private final Context context;
private boolean hasCaughtUpWithOldMessages = false;
String userAgent
) {
this.account = account;
- this.serviceEnvironmentConfig = serviceEnvironmentConfig;
final var credentialsProvider = new DynamicCredentialsProvider(account.getAci(),
account.getAccount(),
dependencies,
account::getProfileKey,
this::getRecipientProfile);
+ this.recipientHelper = new RecipientHelper(account, dependencies, serviceEnvironmentConfig);
this.profileHelper = new ProfileHelper(account,
dependencies,
avatarStore,
unidentifiedAccessHelper::getAccessFor,
- this::resolveSignalServiceAddress);
+ recipientHelper::resolveSignalServiceAddress);
final GroupV2Helper groupV2Helper = new GroupV2Helper(profileHelper,
account::getSelfRecipientId,
dependencies.getGroupsV2Operations(),
dependencies.getGroupsV2Api(),
- this::resolveSignalServiceAddress);
+ recipientHelper::resolveSignalServiceAddress);
this.sendHelper = new SendHelper(account,
dependencies,
unidentifiedAccessHelper,
- this::resolveSignalServiceAddress,
+ recipientHelper::resolveSignalServiceAddress,
account.getRecipientStore(),
this::handleIdentityFailure,
this::getGroupInfo,
profileHelper,
- this::refreshRegisteredUser);
+ recipientHelper::refreshRegisteredUser);
this.groupHelper = new GroupHelper(account,
dependencies,
attachmentHelper,
sendHelper,
groupV2Helper,
avatarStore,
- this::resolveSignalServiceAddress,
+ recipientHelper::resolveSignalServiceAddress,
account.getRecipientStore());
this.storageHelper = new StorageHelper(account, dependencies, groupHelper, profileHelper);
this.contactHelper = new ContactHelper(account);
sendHelper,
groupHelper,
avatarStore,
- this::resolveSignalServiceAddress);
+ recipientHelper::resolveSignalServiceAddress);
preKeyHelper = new PreKeyHelper(account, dependencies);
this.context = new Context(account,
this.incomingMessageHandler = new IncomingMessageHandler(account,
dependencies,
account.getRecipientStore(),
- this::resolveSignalServiceAddress,
+ recipientHelper::resolveSignalServiceAddress,
groupHelper,
contactHelper,
attachmentHelper,
jobExecutor);
this.identityHelper = new IdentityHelper(account,
dependencies,
- this::resolveSignalServiceAddress,
+ recipientHelper::resolveSignalServiceAddress,
syncHelper,
profileHelper);
}
*/
@Override
public Map<String, Pair<String, UUID>> areUsersRegistered(Set<String> numbers) throws IOException {
- Map<String, String> canonicalizedNumbers = numbers.stream().collect(Collectors.toMap(n -> n, n -> {
+ final var canonicalizedNumbers = numbers.stream().collect(Collectors.toMap(n -> n, n -> {
try {
final var canonicalizedNumber = PhoneNumberFormatter.formatNumber(n, account.getAccount());
if (!canonicalizedNumber.equals(n)) {
}));
// Note "registeredUsers" has no optionals. It only gives us info on users who are registered
- var registeredUsers = getRegisteredUsers(canonicalizedNumbers.values()
+ final var canonicalizedNumbersSet = canonicalizedNumbers.values()
.stream()
.filter(s -> !s.isEmpty())
- .collect(Collectors.toSet()));
+ .collect(Collectors.toSet());
+ final var registeredUsers = recipientHelper.getRegisteredUsers(canonicalizedNumbersSet);
return numbers.stream().collect(Collectors.toMap(n -> n, n -> {
final var number = canonicalizedNumbers.get(n);
@Override
public Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws IOException {
- return profileHelper.getRecipientProfile(resolveRecipient(recipient));
+ return profileHelper.getRecipientProfile(recipientHelper.resolveRecipient(recipient));
}
private Profile getRecipientProfile(RecipientId recipientId) {
public SendGroupMessageResults quitGroup(
GroupId groupId, Set<RecipientIdentifier.Single> groupAdmins
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException {
- final var newAdmins = resolveRecipients(groupAdmins);
+ final var newAdmins = recipientHelper.resolveRecipients(groupAdmins);
return groupHelper.quitGroup(groupId, newAdmins);
}
public Pair<GroupId, SendGroupMessageResults> createGroup(
String name, Set<RecipientIdentifier.Single> members, File avatarFile
) throws IOException, AttachmentInvalidException {
- return groupHelper.createGroup(name, members == null ? null : resolveRecipients(members), avatarFile);
+ return groupHelper.createGroup(name,
+ members == null ? null : recipientHelper.resolveRecipients(members),
+ avatarFile);
}
@Override
return groupHelper.updateGroup(groupId,
updateGroup.getName(),
updateGroup.getDescription(),
- updateGroup.getMembers() == null ? null : resolveRecipients(updateGroup.getMembers()),
- updateGroup.getRemoveMembers() == null ? null : resolveRecipients(updateGroup.getRemoveMembers()),
- updateGroup.getAdmins() == null ? null : resolveRecipients(updateGroup.getAdmins()),
- updateGroup.getRemoveAdmins() == null ? null : resolveRecipients(updateGroup.getRemoveAdmins()),
+ updateGroup.getMembers() == null ? null : recipientHelper.resolveRecipients(updateGroup.getMembers()),
+ updateGroup.getRemoveMembers() == null
+ ? null
+ : recipientHelper.resolveRecipients(updateGroup.getRemoveMembers()),
+ updateGroup.getAdmins() == null ? null : recipientHelper.resolveRecipients(updateGroup.getAdmins()),
+ updateGroup.getRemoveAdmins() == null
+ ? null
+ : recipientHelper.resolveRecipients(updateGroup.getRemoveAdmins()),
updateGroup.isResetGroupLink(),
updateGroup.getGroupLinkState(),
updateGroup.getAddMemberPermission(),
messageBuilder.withTimestamp(timestamp);
for (final var recipient : recipients) {
if (recipient instanceof RecipientIdentifier.Single single) {
- final var recipientId = resolveRecipient(single);
+ final var recipientId = recipientHelper.resolveRecipient(single);
final var result = sendHelper.sendMessage(messageBuilder, recipientId);
results.put(recipient,
List.of(SendMessageResult.from(result,
for (var recipient : recipients) {
if (recipient instanceof RecipientIdentifier.Single) {
final var message = new SignalServiceTypingMessage(action, timestamp, Optional.absent());
- final var recipientId = resolveRecipient((RecipientIdentifier.Single) recipient);
+ final var recipientId = recipientHelper.resolveRecipient((RecipientIdentifier.Single) recipient);
final var result = sendHelper.sendTypingMessage(message, recipientId);
results.put(recipient,
List.of(SendMessageResult.from(result,
messageIds,
timestamp);
- final var result = sendHelper.sendReceiptMessage(receiptMessage, resolveRecipient(sender));
+ final var result = sendHelper.sendReceiptMessage(receiptMessage, recipientHelper.resolveRecipient(sender));
return new SendMessageResults(timestamp,
Map.of(sender,
List.of(SendMessageResult.from(result,
messageIds,
timestamp);
- final var result = sendHelper.sendReceiptMessage(receiptMessage, resolveRecipient(sender));
+ final var result = sendHelper.sendReceiptMessage(receiptMessage, recipientHelper.resolveRecipient(sender));
return new SendMessageResults(timestamp,
Map.of(sender,
List.of(SendMessageResult.from(result,
if (message.quote().isPresent()) {
final var quote = message.quote().get();
messageBuilder.withQuote(new SignalServiceDataMessage.Quote(quote.timestamp(),
- resolveSignalServiceAddress(resolveRecipient(quote.author())),
+ recipientHelper.resolveSignalServiceAddress(recipientHelper.resolveRecipient(quote.author())),
quote.message(),
List.of(),
resolveMentions(quote.mentions())));
private ArrayList<SignalServiceDataMessage.Mention> resolveMentions(final List<Message.Mention> mentionList) throws IOException {
final var mentions = new ArrayList<SignalServiceDataMessage.Mention>();
for (final var m : mentionList) {
- final var recipientId = resolveRecipient(m.recipient());
- mentions.add(new SignalServiceDataMessage.Mention(resolveSignalServiceAddress(recipientId).getAci(),
- m.start(),
- m.length()));
+ final var recipientId = recipientHelper.resolveRecipient(m.recipient());
+ mentions.add(new SignalServiceDataMessage.Mention(recipientHelper.resolveSignalServiceAddress(recipientId)
+ .getAci(), m.start(), m.length()));
}
return mentions;
}
long targetSentTimestamp,
Set<RecipientIdentifier> recipients
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
- var targetAuthorRecipientId = resolveRecipient(targetAuthor);
+ var targetAuthorRecipientId = recipientHelper.resolveRecipient(targetAuthor);
var reaction = new SignalServiceDataMessage.Reaction(emoji,
remove,
- resolveSignalServiceAddress(targetAuthorRecipientId),
+ recipientHelper.resolveSignalServiceAddress(targetAuthorRecipientId),
targetSentTimestamp);
final var messageBuilder = SignalServiceDataMessage.newBuilder().withReaction(reaction);
return sendMessage(messageBuilder, recipients);
throw new AssertionError(e);
} finally {
for (var recipient : recipients) {
- final var recipientId = resolveRecipient(recipient);
+ final var recipientId = recipientHelper.resolveRecipient(recipient);
account.getSessionStore().deleteAllSessions(recipientId);
}
}
@Override
public void deleteRecipient(final RecipientIdentifier.Single recipient) throws IOException {
- account.removeRecipient(resolveRecipient(recipient));
+ account.removeRecipient(recipientHelper.resolveRecipient(recipient));
}
@Override
public void deleteContact(final RecipientIdentifier.Single recipient) throws IOException {
- account.getContactStore().deleteContact(resolveRecipient(recipient));
+ account.getContactStore().deleteContact(recipientHelper.resolveRecipient(recipient));
}
@Override
if (!account.isMasterDevice()) {
throw new NotMasterDeviceException();
}
- contactHelper.setContactName(resolveRecipient(recipient), name);
+ contactHelper.setContactName(recipientHelper.resolveRecipient(recipient), name);
}
@Override
if (!account.isMasterDevice()) {
throw new NotMasterDeviceException();
}
- contactHelper.setContactBlocked(resolveRecipient(recipient), blocked);
+ contactHelper.setContactBlocked(recipientHelper.resolveRecipient(recipient), blocked);
// TODO cycle our profile key
syncHelper.sendBlockedList();
}
public void setExpirationTimer(
RecipientIdentifier.Single recipient, int messageExpirationTimer
) throws IOException {
- var recipientId = resolveRecipient(recipient);
+ var recipientId = recipientHelper.resolveRecipient(recipient);
contactHelper.setExpirationTimer(recipientId, messageExpirationTimer);
final var messageBuilder = SignalServiceDataMessage.newBuilder().asExpirationUpdate();
try {
}
}
- private RecipientId refreshRegisteredUser(RecipientId recipientId) throws IOException {
- final var address = resolveSignalServiceAddress(recipientId);
- if (!address.getNumber().isPresent()) {
- return recipientId;
- }
- final var number = address.getNumber().get();
- final var uuid = getRegisteredUser(number);
- return resolveRecipientTrusted(new SignalServiceAddress(uuid, number));
- }
-
- private ACI getRegisteredUser(final String number) throws IOException {
- final Map<String, ACI> aciMap;
- try {
- aciMap = getRegisteredUsers(Set.of(number));
- } catch (NumberFormatException e) {
- throw new UnregisteredUserException(number, e);
- }
- final var uuid = aciMap.get(number);
- if (uuid == null) {
- throw new UnregisteredUserException(number, null);
- }
- return uuid;
- }
-
- private Map<String, ACI> getRegisteredUsers(final Set<String> numbers) throws IOException {
- final Map<String, ACI> registeredUsers;
- try {
- registeredUsers = dependencies.getAccountManager()
- .getRegisteredUsers(ServiceConfig.getIasKeyStore(),
- numbers,
- serviceEnvironmentConfig.getCdsMrenclave());
- } catch (Quote.InvalidQuoteFormatException | UnauthenticatedQuoteException | SignatureException | UnauthenticatedResponseException | InvalidKeyException e) {
- throw new IOException(e);
- }
-
- // Store numbers as recipients, so we have the number/uuid association
- registeredUsers.forEach((number, aci) -> resolveRecipientTrusted(new SignalServiceAddress(aci, number)));
-
- return registeredUsers;
- }
-
private void retryFailedReceivedMessages(ReceiveMessageHandler handler) {
Set<HandleAction> queuedActions = new HashSet<>();
for (var cachedMessage : account.getMessageCache().getCachedMessages()) {
if (exception instanceof UntrustedIdentityException) {
logger.debug("Keeping message with untrusted identity in message cache");
final var address = ((UntrustedIdentityException) exception).getSender();
- final var recipientId = resolveRecipient(address);
+ final var recipientId = account.getRecipientStore().resolveRecipient(address);
if (!envelope.hasSourceUuid()) {
try {
cachedMessage[0] = account.getMessageCache().replaceSender(cachedMessage[0], recipientId);
public boolean isContactBlocked(final RecipientIdentifier.Single recipient) {
final RecipientId recipientId;
try {
- recipientId = resolveRecipient(recipient);
+ recipientId = recipientHelper.resolveRecipient(recipient);
} catch (IOException e) {
return false;
}
public String getContactOrProfileName(RecipientIdentifier.Single recipient) {
final RecipientId recipientId;
try {
- recipientId = resolveRecipient(recipient);
+ recipientId = recipientHelper.resolveRecipient(recipient);
} catch (IOException e) {
return null;
}
public List<Identity> getIdentities(RecipientIdentifier.Single recipient) {
IdentityInfo identity;
try {
- identity = account.getIdentityKeyStore().getIdentity(resolveRecipient(recipient));
+ identity = account.getIdentityKeyStore().getIdentity(recipientHelper.resolveRecipient(recipient));
} catch (IOException e) {
identity = null;
}
public boolean trustIdentityVerified(RecipientIdentifier.Single recipient, byte[] fingerprint) {
RecipientId recipientId;
try {
- recipientId = resolveRecipient(recipient);
+ recipientId = recipientHelper.resolveRecipient(recipient);
} catch (IOException e) {
return false;
}
public boolean trustIdentityVerifiedSafetyNumber(RecipientIdentifier.Single recipient, String safetyNumber) {
RecipientId recipientId;
try {
- recipientId = resolveRecipient(recipient);
+ recipientId = recipientHelper.resolveRecipient(recipient);
} catch (IOException e) {
return false;
}
public boolean trustIdentityVerifiedSafetyNumber(RecipientIdentifier.Single recipient, byte[] safetyNumber) {
RecipientId recipientId;
try {
- recipientId = resolveRecipient(recipient);
+ recipientId = recipientHelper.resolveRecipient(recipient);
} catch (IOException e) {
return false;
}
public boolean trustIdentityAllKeys(RecipientIdentifier.Single recipient) {
RecipientId recipientId;
try {
- recipientId = resolveRecipient(recipient);
+ recipientId = recipientHelper.resolveRecipient(recipient);
} catch (IOException e) {
return false;
}
this.identityHelper.handleIdentityFailure(recipientId, identityFailure);
}
- private SignalServiceAddress resolveSignalServiceAddress(RecipientId recipientId) {
- final var address = account.getRecipientStore().resolveRecipientAddress(recipientId);
- if (address.uuid().isPresent()) {
- return address.toSignalServiceAddress();
- }
-
- // Address in recipient store doesn't have a uuid, this shouldn't happen
- // Try to retrieve the uuid from the server
- final var number = address.number().get();
- final ACI aci;
- try {
- aci = getRegisteredUser(number);
- } catch (IOException e) {
- logger.warn("Failed to get uuid for e164 number: {}", number, e);
- // Return SignalServiceAddress with unknown UUID
- return address.toSignalServiceAddress();
- }
- return resolveSignalServiceAddress(account.getRecipientStore().resolveRecipient(aci));
- }
-
- private Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws IOException {
- final var recipientIds = new HashSet<RecipientId>(recipients.size());
- for (var number : recipients) {
- final var recipientId = resolveRecipient(number);
- recipientIds.add(recipientId);
- }
- return recipientIds;
- }
-
- private RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws IOException {
- if (recipient instanceof RecipientIdentifier.Uuid uuidRecipient) {
- return account.getRecipientStore().resolveRecipient(ACI.from(uuidRecipient.uuid()));
- } else {
- final var number = ((RecipientIdentifier.Number) recipient).number();
- return account.getRecipientStore().resolveRecipient(number, () -> {
- try {
- return getRegisteredUser(number);
- } catch (IOException e) {
- return null;
- }
- });
- }
- }
-
- private RecipientId resolveRecipient(RecipientAddress address) {
- return account.getRecipientStore().resolveRecipient(address);
- }
-
private RecipientId resolveRecipient(SignalServiceAddress address) {
return account.getRecipientStore().resolveRecipient(address);
}
- private RecipientId resolveRecipientTrusted(SignalServiceAddress address) {
- return account.getRecipientStore().resolveRecipientTrusted(address);
- }
-
@Override
public void close() throws IOException {
Thread thread;
--- /dev/null
+package org.asamk.signal.manager.helper;
+
+import org.asamk.signal.manager.SignalDependencies;
+import org.asamk.signal.manager.api.RecipientIdentifier;
+import org.asamk.signal.manager.config.ServiceConfig;
+import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
+import org.asamk.signal.manager.storage.SignalAccount;
+import org.asamk.signal.manager.storage.recipients.RecipientId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.whispersystems.libsignal.InvalidKeyException;
+import org.whispersystems.signalservice.api.push.ACI;
+import org.whispersystems.signalservice.api.push.SignalServiceAddress;
+import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
+import org.whispersystems.signalservice.internal.contacts.crypto.Quote;
+import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedQuoteException;
+import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
+
+import java.io.IOException;
+import java.security.SignatureException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class RecipientHelper {
+
+ private final static Logger logger = LoggerFactory.getLogger(RecipientHelper.class);
+
+ private final SignalAccount account;
+ private final SignalDependencies dependencies;
+ private final ServiceEnvironmentConfig serviceEnvironmentConfig;
+
+ public RecipientHelper(
+ final SignalAccount account,
+ final SignalDependencies dependencies,
+ final ServiceEnvironmentConfig serviceEnvironmentConfig
+ ) {
+ this.account = account;
+ this.dependencies = dependencies;
+ this.serviceEnvironmentConfig = serviceEnvironmentConfig;
+ }
+
+ public SignalServiceAddress resolveSignalServiceAddress(RecipientId recipientId) {
+ final var address = account.getRecipientStore().resolveRecipientAddress(recipientId);
+ if (address.number().isEmpty() || address.uuid().isPresent()) {
+ return address.toSignalServiceAddress();
+ }
+
+ // Address in recipient store doesn't have a uuid, this shouldn't happen
+ // Try to retrieve the uuid from the server
+ final var number = address.number().get();
+ final ACI aci;
+ try {
+ aci = getRegisteredUser(number);
+ } catch (IOException e) {
+ logger.warn("Failed to get uuid for e164 number: {}", number, e);
+ // Return SignalServiceAddress with unknown UUID
+ return address.toSignalServiceAddress();
+ }
+ return account.getRecipientStore()
+ .resolveRecipientAddress(account.getRecipientStore().resolveRecipient(aci))
+ .toSignalServiceAddress();
+ }
+
+ public Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws IOException {
+ final var recipientIds = new HashSet<RecipientId>(recipients.size());
+ for (var number : recipients) {
+ final var recipientId = resolveRecipient(number);
+ recipientIds.add(recipientId);
+ }
+ return recipientIds;
+ }
+
+ public RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws IOException {
+ if (recipient instanceof RecipientIdentifier.Uuid uuidRecipient) {
+ return account.getRecipientStore().resolveRecipient(ACI.from(uuidRecipient.uuid()));
+ } else {
+ final var number = ((RecipientIdentifier.Number) recipient).number();
+ return account.getRecipientStore().resolveRecipient(number, () -> {
+ try {
+ return getRegisteredUser(number);
+ } catch (IOException e) {
+ return null;
+ }
+ });
+ }
+ }
+
+ public RecipientId refreshRegisteredUser(RecipientId recipientId) throws IOException {
+ final var address = resolveSignalServiceAddress(recipientId);
+ if (!address.getNumber().isPresent()) {
+ return recipientId;
+ }
+ final var number = address.getNumber().get();
+ final var uuid = getRegisteredUser(number);
+ return account.getRecipientStore().resolveRecipientTrusted(new SignalServiceAddress(uuid, number));
+ }
+
+ public Map<String, ACI> getRegisteredUsers(final Set<String> numbers) throws IOException {
+ final Map<String, ACI> registeredUsers;
+ try {
+ registeredUsers = dependencies.getAccountManager()
+ .getRegisteredUsers(ServiceConfig.getIasKeyStore(),
+ numbers,
+ serviceEnvironmentConfig.getCdsMrenclave());
+ } catch (Quote.InvalidQuoteFormatException | UnauthenticatedQuoteException | SignatureException | UnauthenticatedResponseException | InvalidKeyException e) {
+ throw new IOException(e);
+ }
+
+ // Store numbers as recipients, so we have the number/uuid association
+ registeredUsers.forEach((number, aci) -> account.getRecipientStore()
+ .resolveRecipientTrusted(new SignalServiceAddress(aci, number)));
+
+ return registeredUsers;
+ }
+
+ private ACI getRegisteredUser(final String number) throws IOException {
+ final Map<String, ACI> aciMap;
+ try {
+ aciMap = getRegisteredUsers(Set.of(number));
+ } catch (NumberFormatException e) {
+ throw new UnregisteredUserException(number, e);
+ }
+ final var uuid = aciMap.get(number);
+ if (uuid == null) {
+ throw new UnregisteredUserException(number, null);
+ }
+ return uuid;
+ }
+}