mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Store username aci link in recipient store
This commit is contained in:
parent
733c14bbc8
commit
1addffe622
2 changed files with 9 additions and 19 deletions
|
@ -229,7 +229,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
public RecipientId resolveRecipientByUsername(
|
||||
final String username, Supplier<ServiceId> serviceIdSupplier
|
||||
final String username, Supplier<ACI> aciSupplier
|
||||
) throws UnregisteredRecipientException {
|
||||
final Optional<RecipientWithAddress> byUsername;
|
||||
try (final var connection = database.getConnection()) {
|
||||
|
@ -238,14 +238,14 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
throw new RuntimeException("Failed read from recipient store", e);
|
||||
}
|
||||
if (byUsername.isEmpty() || byUsername.get().address().serviceId().isEmpty()) {
|
||||
final var serviceId = serviceIdSupplier.get();
|
||||
if (serviceId == null) {
|
||||
final var aci = aciSupplier.get();
|
||||
if (aci == null) {
|
||||
throw new UnregisteredRecipientException(new org.asamk.signal.manager.api.RecipientAddress(null,
|
||||
null,
|
||||
username));
|
||||
}
|
||||
|
||||
return resolveRecipient(serviceId);
|
||||
return resolveRecipientTrusted(aci, username);
|
||||
}
|
||||
return byUsername.get().id();
|
||||
}
|
||||
|
@ -287,17 +287,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
@Override
|
||||
public RecipientId resolveRecipientTrusted(final ServiceId serviceId, final String username) {
|
||||
return resolveRecipientTrusted(new RecipientAddress(serviceId, null, null, username), false);
|
||||
}
|
||||
|
||||
public RecipientId resolveRecipientTrusted(
|
||||
final ACI aci, final String username
|
||||
) {
|
||||
return resolveRecipientTrusted(new RecipientAddress(Optional.of(aci),
|
||||
Optional.empty(),
|
||||
Optional.empty(),
|
||||
Optional.of(username)), false);
|
||||
public RecipientId resolveRecipientTrusted(final ACI aci, final String username) {
|
||||
return resolveRecipientTrusted(new RecipientAddress(aci, null, null, username), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.asamk.signal.manager.storage.recipients;
|
||||
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.PNI;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
|
@ -16,7 +15,7 @@ public interface RecipientTrustedResolver {
|
|||
|
||||
RecipientId resolveRecipientTrusted(Optional<ACI> aci, Optional<PNI> pni, Optional<String> number);
|
||||
|
||||
RecipientId resolveRecipientTrusted(ServiceId serviceId, String username);
|
||||
RecipientId resolveRecipientTrusted(ACI aci, String username);
|
||||
|
||||
class RecipientTrustedResolverWrapper implements RecipientTrustedResolver {
|
||||
|
||||
|
@ -44,8 +43,8 @@ public interface RecipientTrustedResolver {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RecipientId resolveRecipientTrusted(final ServiceId serviceId, final String username) {
|
||||
return recipientTrustedResolverSupplier.get().resolveRecipientTrusted(serviceId, username);
|
||||
public RecipientId resolveRecipientTrusted(final ACI aci, final String username) {
|
||||
return recipientTrustedResolverSupplier.get().resolveRecipientTrusted(aci, username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue