]> nmode's Git Repositories - signal-cli/commitdiff
Improve uuid/number handling
authorAsamK <asamk@gmx.de>
Sun, 11 Jun 2023 14:39:54 +0000 (16:39 +0200)
committerAsamK <asamk@gmx.de>
Sun, 11 Jun 2023 14:39:54 +0000 (16:39 +0200)
man/signal-cli-dbus.5.adoc
src/main/java/org/asamk/Signal.java
src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java

index 0f11ef9d4c7a3bef26be23e22d38a9db4e74e8cf..1f2caa1812d1d0a9d43e8e7a26f7f83b66863947 100644 (file)
@@ -422,12 +422,12 @@ listIdentities() -> identities<a(oss)>::
 * identities : Array of structs (objectPath, id, name)
 ** objectPath : DBusPath representing the identity object path
 ** uuid : Internal uuid of the identity
-** number : Phone number of the identity (or uuid if not known)
+** number : Phone number of the identity
 
 Lists all know identities
 
 getIdentity(Number<s>) -> identityPath<o>::
-* Number : Phone number 
+* Number : Phone number
 * identityPath : DBusPath object for the identity
 
 Gets the identity Dbus path for a given phone number
@@ -575,13 +575,15 @@ To get all properties, use:
 
 trust() -> <>::
 
-Establish trust with the given identity. TrustLevel will become TRUSTED_UNVERFIED
+Establish trust with the given identity.
+TrustLevel will become TRUSTED_UNVERFIED
 
 Exceptions: Failure
 
 trustVerified(SafetyNumber<s>) -> <>::
 
-Establish trust with the given identity using their safety number. TrustLevel will become TRUSTED_VERIFIED
+Establish trust with the given identity using their safety number.
+TrustLevel will become TRUSTED_VERIFIED
 
 Exceptions: Failure
 
index 0a508548464b4983d3aeb0a2ad50dd118495dd39..9bffd6afd92016cf7c5d22435bd6e11fefc204a4 100644 (file)
@@ -564,12 +564,12 @@ public interface Signal extends DBusInterface {
         String uuid;
 
         @Position(2)
-        String name;
+        String number;
 
-        public StructIdentity(final DBusPath objectPath, final String uuid, final String name) {
+        public StructIdentity(final DBusPath objectPath, final String uuid, final String number) {
             this.objectPath = objectPath;
             this.uuid = uuid;
-            this.name = name;
+            this.number = number;
         }
 
         public DBusPath getObjectPath() {
@@ -580,8 +580,8 @@ public interface Signal extends DBusInterface {
             return uuid;
         }
 
-        public String getName() {
-            return name;
+        public String getNumber() {
+            return number;
         }
     }
 
index f6ea4eef1072dc350212f2038e20fb451a1e78de..fef6821a7572ef9495ea14815af5d2e8a53f64d6 100644 (file)
@@ -1044,8 +1044,8 @@ public class DbusSignalImpl implements Signal {
             final var object = new DbusSignalIdentityImpl(i);
             exportObject(object);
             this.identities.add(new StructIdentity(new DBusPath(object.getObjectPath()),
-                    emptyIfNull(i.recipient().getIdentifier()),
-                    i.recipient().getLegacyIdentifier()));
+                    i.recipient().uuid().map(UUID::toString).orElse(""),
+                    i.recipient().number().orElse("")));
         });
     }
 
@@ -1063,11 +1063,12 @@ public class DbusSignalImpl implements Signal {
 
     @Override
     public DBusPath getIdentity(String number) throws Error.Failure {
-
-        final var found = identities.stream().filter(identity -> identity.getName().equals(number)).findFirst();
+        final var found = identities.stream()
+                .filter(identity -> identity.getNumber().equals(number) || identity.getUuid().equals(number))
+                .findFirst();
 
         if (found.isEmpty()) {
-            throw new Error.Failure("Identity for " + number + " unkown");
+            throw new Error.Failure("Identity for " + number + " unknown");
         }
         return found.get().getObjectPath();
     }
@@ -1088,7 +1089,7 @@ public class DbusSignalImpl implements Signal {
                     List.of(new DbusProperty<>("Number", () -> identity.recipient().number().orElse("")),
                             new DbusProperty<>("Uuid",
                                     () -> identity.recipient().uuid().map(UUID::toString).orElse("")),
-                            new DbusProperty<>("Fingerprint", () -> identity.getFingerprint()),
+                            new DbusProperty<>("Fingerprint", identity::getFingerprint),
                             new DbusProperty<>("SafetyNumber", identity::safetyNumber),
                             new DbusProperty<>("ScannableSafetyNumber", identity::scannableSafetyNumber),
                             new DbusProperty<>("TrustLevel", identity::trustLevel),
@@ -1181,8 +1182,7 @@ public class DbusSignalImpl implements Signal {
 
     public class DbusSignalConfigurationImpl extends DbusProperties implements Signal.Configuration {
 
-        public DbusSignalConfigurationImpl(
-        ) {
+        public DbusSignalConfigurationImpl() {
             super.addPropertiesHandler(new DbusInterfacePropertiesHandler("org.asamk.Signal.Configuration",
                     List.of(new DbusProperty<>("ReadReceipts", this::getReadReceipts, this::setReadReceipts),
                             new DbusProperty<>("UnidentifiedDeliveryIndicators",