]> nmode's Git Repositories - signal-cli/commitdiff
Store username aci link in recipient store
authorAsamK <asamk@gmx.de>
Tue, 17 Oct 2023 12:58:15 +0000 (14:58 +0200)
committerAsamK <asamk@gmx.de>
Tue, 17 Oct 2023 12:58:15 +0000 (14:58 +0200)
lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java
lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientTrustedResolver.java

index 9731496eec4d8c1cfa24af1efc29e93c82c072c8..816ac791704bc76038205b110f645a7112afbf9a 100644 (file)
@@ -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
index 54e5d5d15bdd68f6b7475e1e6d0bdb8fe1955364..21708551ac7845f4332a9a2a74d410df702ba4e9 100644 (file)
@@ -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);
         }
     }
 }