]> nmode's Git Repositories - signal-cli/commitdiff
Extend updateContact command with nick given/family name and note
authorAsamK <asamk@gmx.de>
Thu, 23 Jan 2025 16:11:33 +0000 (17:11 +0100)
committerAsamK <asamk@gmx.de>
Thu, 23 Jan 2025 16:11:33 +0000 (17:11 +0100)
lib/src/main/java/org/asamk/signal/manager/Manager.java
lib/src/main/java/org/asamk/signal/manager/helper/ContactHelper.java
lib/src/main/java/org/asamk/signal/manager/internal/ManagerImpl.java
man/signal-cli.1.adoc
src/main/java/org/asamk/signal/commands/UpdateContactCommand.java
src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java
src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java

index 85644f61104d657471bd82eddf1708e0e7755eb7..bdb3dbc97f4d144f2caad406285261c9fe413b83 100644 (file)
@@ -237,9 +237,12 @@ public interface Manager extends Closeable {
     void deleteContact(RecipientIdentifier.Single recipient);
 
     void setContactName(
     void deleteContact(RecipientIdentifier.Single recipient);
 
     void setContactName(
-            RecipientIdentifier.Single recipient,
-            String givenName,
-            final String familyName
+            final RecipientIdentifier.Single recipient,
+            final String givenName,
+            final String familyName,
+            final String nickGivenName,
+            final String nickFamilyName,
+            final String note
     ) throws NotPrimaryDeviceException, UnregisteredRecipientException;
 
     void setContactsBlocked(
     ) throws NotPrimaryDeviceException, UnregisteredRecipientException;
 
     void setContactsBlocked(
index fafb9ffeb321f745400dcab5ee1cd4c51efd40bb..8461fbe0fd66483e03703af04cc5a9dcc074c5e0 100644 (file)
@@ -17,7 +17,14 @@ public class ContactHelper {
         return sourceContact != null && sourceContact.isBlocked();
     }
 
         return sourceContact != null && sourceContact.isBlocked();
     }
 
-    public void setContactName(final RecipientId recipientId, final String givenName, final String familyName) {
+    public void setContactName(
+            final RecipientId recipientId,
+            final String givenName,
+            final String familyName,
+            final String nickGivenName,
+            final String nickFamilyName,
+            final String note
+    ) {
         var contact = account.getContactStore().getContact(recipientId);
         final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
         builder.withIsHidden(false);
         var contact = account.getContactStore().getContact(recipientId);
         final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
         builder.withIsHidden(false);
@@ -27,6 +34,15 @@ public class ContactHelper {
         if (familyName != null) {
             builder.withFamilyName(familyName);
         }
         if (familyName != null) {
             builder.withFamilyName(familyName);
         }
+        if (nickGivenName != null) {
+            builder.withNickNameGivenName(nickGivenName);
+        }
+        if (nickFamilyName != null) {
+            builder.withNickNameFamilyName(nickFamilyName);
+        }
+        if (note != null) {
+            builder.withNote(note);
+        }
         account.getContactStore().storeContact(recipientId, builder.build());
     }
 
         account.getContactStore().storeContact(recipientId, builder.build());
     }
 
index 4315f50ba2c869b9bd79f7f61136ed617c3adcdf..403b9adf7d3ac5ebd9ec7818d2c70eb9ea7187d4 100644 (file)
@@ -1049,15 +1049,23 @@ public class ManagerImpl implements Manager {
 
     @Override
     public void setContactName(
 
     @Override
     public void setContactName(
-            RecipientIdentifier.Single recipient,
-            String givenName,
-            final String familyName
+            final RecipientIdentifier.Single recipient,
+            final String givenName,
+            final String familyName,
+            final String nickGivenName,
+            final String nickFamilyName,
+            final String note
     ) throws NotPrimaryDeviceException, UnregisteredRecipientException {
         if (!account.isPrimaryDevice()) {
             throw new NotPrimaryDeviceException();
         }
         context.getContactHelper()
     ) throws NotPrimaryDeviceException, UnregisteredRecipientException {
         if (!account.isPrimaryDevice()) {
             throw new NotPrimaryDeviceException();
         }
         context.getContactHelper()
-                .setContactName(context.getRecipientHelper().resolveRecipient(recipient), givenName, familyName);
+                .setContactName(context.getRecipientHelper().resolveRecipient(recipient),
+                        givenName,
+                        familyName,
+                        nickGivenName,
+                        nickFamilyName,
+                        note);
         syncRemoteStorage();
     }
 
         syncRemoteStorage();
     }
 
index 4196f9919348cb1acb29278452bcc2aab1437e71..48b821dfc88e0edb6fa58f345e2b1d296d64f335 100644 (file)
@@ -669,11 +669,20 @@ If the contact doesn't exist yet, it will be added.
 RECIPIENT::
 Specify the recipient.
 
 RECIPIENT::
 Specify the recipient.
 
-*--given-name* NAME, *--name* NAME::
-New (given) name.
+*--given-name* GIVEN_NAME, *--name* NAME::
+New system given name.
 
 *--family-name* FAMILY_NAME::
 
 *--family-name* FAMILY_NAME::
-New family name.
+New system family name.
+
+*--nick-given-name* NICK_GIVEN_NAME::
+New nick given name.
+
+*--nick-family-name* NICK_FAMILY_NAME::
+New nick family name.
+
+*--note* NOTE::
+New note.
 
 *-e*, *--expiration* EXPIRATION_SECONDS::
 Set expiration time of messages (seconds).
 
 *-e*, *--expiration* EXPIRATION_SECONDS::
 Set expiration time of messages (seconds).
index 815c15da0004447ae3b470563b6692d068326af8..312ac8e86a0ef7a60685f7f95cfb5c1df5477d47 100644 (file)
@@ -26,8 +26,11 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
         subparser.help("Update the details of a given contact");
         subparser.addArgument("recipient").help("Contact number");
         subparser.addArgument("-n", "--name").help("New contact name");
         subparser.help("Update the details of a given contact");
         subparser.addArgument("recipient").help("Contact number");
         subparser.addArgument("-n", "--name").help("New contact name");
-        subparser.addArgument("--given-name").help("New contact given name");
-        subparser.addArgument("--family-name").help("New contact family name");
+        subparser.addArgument("--given-name").help("New system given name");
+        subparser.addArgument("--family-name").help("New system family name");
+        subparser.addArgument("--nick-given-name").help("New nick given name");
+        subparser.addArgument("--nick-family-name").help("New nick family name");
+        subparser.addArgument("--note").help("New note");
         subparser.addArgument("-e", "--expiration").type(int.class).help("Set expiration time of messages (seconds)");
     }
 
         subparser.addArgument("-e", "--expiration").type(int.class).help("Set expiration time of messages (seconds)");
     }
 
@@ -54,8 +57,15 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
                     familyName = "";
                 }
             }
                     familyName = "";
                 }
             }
-            if (givenName != null || familyName != null) {
-                m.setContactName(recipient, givenName, familyName);
+            var nickGivenName = ns.getString("nick-given-name");
+            var nickFamilyName = ns.getString("nick-family-name");
+            var note = ns.getString("note");
+            if (givenName != null
+                    || familyName != null
+                    || nickGivenName != null
+                    || nickFamilyName != null
+                    || note != null) {
+                m.setContactName(recipient, givenName, familyName, nickGivenName, nickFamilyName, note);
             }
         } catch (IOException e) {
             throw new IOErrorException("Update contact error: " + e.getMessage(), e);
             }
         } catch (IOException e) {
             throw new IOErrorException("Update contact error: " + e.getMessage(), e);
index 159407e194d396409fe5c4af244753228b22795a..5658d0d32634f8e67136a53e34a070ae2abc169d 100644 (file)
@@ -516,7 +516,10 @@ public class DbusManagerImpl implements Manager {
     public void setContactName(
             final RecipientIdentifier.Single recipient,
             final String givenName,
     public void setContactName(
             final RecipientIdentifier.Single recipient,
             final String givenName,
-            final String familyName
+            final String familyName,
+            final String nickGivenName,
+            final String nickFamilyName,
+            final String note
     ) throws NotPrimaryDeviceException {
         signal.setContactName(recipient.getIdentifier(), givenName);
     }
     ) throws NotPrimaryDeviceException {
         signal.setContactName(recipient.getIdentifier(), givenName);
     }
index bbae26b5715436df77785ac9dc6f1d9523d6ed5b..ac77df99d2500d23269e4bd69a201f814795fc78 100644 (file)
@@ -531,7 +531,7 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
     @Override
     public void setContactName(final String number, final String name) {
         try {
     @Override
     public void setContactName(final String number, final String name) {
         try {
-            m.setContactName(getSingleRecipientIdentifier(number, m.getSelfNumber()), name, "");
+            m.setContactName(getSingleRecipientIdentifier(number, m.getSelfNumber()), name, "", null, null, null);
         } catch (NotPrimaryDeviceException e) {
             throw new Error.Failure("This command doesn't work on linked devices.");
         } catch (UnregisteredRecipientException e) {
         } catch (NotPrimaryDeviceException e) {
             throw new Error.Failure("This command doesn't work on linked devices.");
         } catch (UnregisteredRecipientException e) {