]> nmode's Git Repositories - signal-cli/commitdiff
Extend updateProfile command to set family name
authorAsamK <asamk@gmx.de>
Wed, 5 May 2021 17:32:52 +0000 (19:32 +0200)
committerAsamK <asamk@gmx.de>
Wed, 5 May 2021 17:32:52 +0000 (19:32 +0200)
lib/src/main/java/org/asamk/signal/manager/Manager.java
lib/src/main/java/org/asamk/signal/manager/RegistrationManager.java
man/signal-cli.1.adoc
src/main/java/org/asamk/signal/commands/UpdateProfileCommand.java
src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java

index b92ffe290e0ddfd8299fbfc1448be5797036e855..05aec952aa02bfe33544883d376dc78eb93bf8a0 100644 (file)
@@ -354,18 +354,22 @@ public class Manager implements Closeable {
     }
 
     /**
     }
 
     /**
-     * @param name       if null, the previous name will be kept
+     * @param givenName  if null, the previous givenName will be kept
+     * @param familyName if null, the previous familyName will be kept
      * @param about      if null, the previous about text will be kept
      * @param aboutEmoji if null, the previous about emoji will be kept
      * @param avatar     if avatar is null the image from the local avatar store is used (if present),
      * @param about      if null, the previous about text will be kept
      * @param aboutEmoji if null, the previous about emoji will be kept
      * @param avatar     if avatar is null the image from the local avatar store is used (if present),
-     *                   if it's Optional.absent(), the avatar will be removed
      */
      */
-    public void setProfile(String name, String about, String aboutEmoji, Optional<File> avatar) throws IOException {
+    public void setProfile(
+            String givenName, final String familyName, String about, String aboutEmoji, Optional<File> avatar
+    ) throws IOException {
         var profile = getRecipientProfile(account.getSelfRecipientId());
         var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
         var profile = getRecipientProfile(account.getSelfRecipientId());
         var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
-        if (name != null) {
-            builder.withGivenName(name);
-            builder.withFamilyName(null);
+        if (givenName != null) {
+            builder.withGivenName(givenName);
+        }
+        if (familyName != null) {
+            builder.withFamilyName(familyName);
         }
         if (about != null) {
             builder.withAbout(about);
         }
         if (about != null) {
             builder.withAbout(about);
index b6d12e29f150e6cf7ed09de0acff6406a5cf9db0..612984edbdd78f50e047eb44b931bb922277b3fb 100644 (file)
@@ -162,7 +162,7 @@ public class RegistrationManager implements Closeable {
 
             m.refreshPreKeys();
             // Set an initial empty profile so user can be added to groups
 
             m.refreshPreKeys();
             // Set an initial empty profile so user can be added to groups
-            m.setProfile(null, null, null, null);
+            m.setProfile(null, null, null, null, null);
 
             final var result = m;
             m = null;
 
             final var result = m;
             m = null;
index af298b2708bd46cbf398624240c75ce839aaae3b..03d9ffafe9bc84998ef07667a766a76b3fbbfb46 100644 (file)
@@ -289,18 +289,28 @@ Specify the safety number of the key, only use this option if you have verified
 
 === updateProfile
 
 
 === updateProfile
 
-Update the name and avatar image visible by message recipients for the current users.
+Update the profile information shown to message recipients.
 The profile is stored encrypted on the Signal servers.
 The profile is stored encrypted on the Signal servers.
-The decryption key is sent with every outgoing messages to contacts.
+The decryption key is sent with every outgoing messages to contacts and included
+in every group.
 
 
-*--name*::
-New name visible by message recipients.
+*--given-name* NAME, *--name* NAME::
+New (given) name.
 
 
-*--avatar*::
-Path to the new avatar visible by message recipients.
+*--family-name* FAMILY_NAME::
+New family name.
+
+*--about* ABOUT_TEXT::
+New profile status text.
+
+*--about-emoji* EMOJI::
+New profile status emoji.
+
+*--avatar* AVATAR_FILE::
+Path to the new avatar image file.
 
 *--remove-avatar*::
 
 *--remove-avatar*::
-Remove the avatar visible by message recipients.
+Remove the avatar
 
 === updateContact
 
 
 === updateContact
 
index c3fc2e8893b7de8221a059367793940bd13922bb..ce578f27837221b1e1da5c8d1ad38e002e943c64 100644 (file)
@@ -16,7 +16,8 @@ public class UpdateProfileCommand implements LocalCommand {
 
     @Override
     public void attachToSubparser(final Subparser subparser) {
 
     @Override
     public void attachToSubparser(final Subparser subparser) {
-        subparser.addArgument("--name").help("New profile name");
+        subparser.addArgument("--given-name", "--name").help("New profile (given) name");
+        subparser.addArgument("--family-name").help("New profile family name (optional)");
         subparser.addArgument("--about").help("New profile about text");
         subparser.addArgument("--about-emoji").help("New profile about emoji");
 
         subparser.addArgument("--about").help("New profile about text");
         subparser.addArgument("--about-emoji").help("New profile about emoji");
 
@@ -29,7 +30,8 @@ public class UpdateProfileCommand implements LocalCommand {
 
     @Override
     public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
 
     @Override
     public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
-        var name = ns.getString("name");
+        var givenName = ns.getString("given_name");
+        var familyName = ns.getString("family_name");
         var about = ns.getString("about");
         var aboutEmoji = ns.getString("about_emoji");
         var avatarPath = ns.getString("avatar");
         var about = ns.getString("about");
         var aboutEmoji = ns.getString("about_emoji");
         var avatarPath = ns.getString("avatar");
@@ -40,7 +42,7 @@ public class UpdateProfileCommand implements LocalCommand {
                 : avatarPath == null ? null : Optional.of(new File(avatarPath));
 
         try {
                 : avatarPath == null ? null : Optional.of(new File(avatarPath));
 
         try {
-            m.setProfile(name, about, aboutEmoji, avatarFile);
+            m.setProfile(givenName, familyName, about, aboutEmoji, avatarFile);
         } catch (IOException e) {
             throw new IOErrorException("Update profile error: " + e.getMessage());
         }
         } catch (IOException e) {
             throw new IOErrorException("Update profile error: " + e.getMessage());
         }
index 9eda62504e89f2e12dfbd8493b4d0846e4000a85..325ae7a1da3e0f4eb85c83813dfa16902e01789b 100644 (file)
@@ -372,7 +372,7 @@ public class DbusSignalImpl implements Signal {
             Optional<File> avatarFile = removeAvatar
                     ? Optional.absent()
                     : avatarPath == null ? null : Optional.of(new File(avatarPath));
             Optional<File> avatarFile = removeAvatar
                     ? Optional.absent()
                     : avatarPath == null ? null : Optional.of(new File(avatarPath));
-            m.setProfile(name, about, aboutEmoji, avatarFile);
+            m.setProfile(name, null, about, aboutEmoji, avatarFile);
         } catch (IOException e) {
             throw new Error.Failure(e.getMessage());
         }
         } catch (IOException e) {
             throw new Error.Failure(e.getMessage());
         }