mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
parent
a3bc754e80
commit
760934d5a5
2 changed files with 15 additions and 1 deletions
|
@ -107,9 +107,13 @@ public class RecipientHelper {
|
|||
try {
|
||||
return Optional.of(resolveRecipient(recipient));
|
||||
} catch (UnregisteredRecipientException e) {
|
||||
if (recipient instanceof RecipientIdentifier.Number r) {
|
||||
return account.getRecipientStore().resolveRecipientByNumberOptional(r.number());
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RecipientId refreshRegisteredUser(RecipientId recipientId) throws IOException, UnregisteredRecipientException {
|
||||
final var address = resolveSignalServiceAddress(recipientId);
|
||||
|
|
|
@ -215,6 +215,16 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
return byNumber.get().id();
|
||||
}
|
||||
|
||||
public Optional<RecipientId> resolveRecipientByNumberOptional(final String number) {
|
||||
final Optional<RecipientWithAddress> byNumber;
|
||||
try (final var connection = database.getConnection()) {
|
||||
byNumber = findByNumber(connection, number);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("Failed read from recipient store", e);
|
||||
}
|
||||
return byNumber.map(RecipientWithAddress::id);
|
||||
}
|
||||
|
||||
public RecipientId resolveRecipientByUsername(
|
||||
final String username, Supplier<ServiceId> serviceIdSupplier
|
||||
) throws UnregisteredRecipientException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue