]> nmode's Git Repositories - signal-cli/commitdiff
Add command to update account attributes
authorAsamK <asamk@gmx.de>
Sat, 18 Feb 2017 11:03:17 +0000 (12:03 +0100)
committerAsamK <asamk@gmx.de>
Sat, 18 Feb 2017 11:35:32 +0000 (12:35 +0100)
This can fix problems with receiving messages, if for some reason, the
fetchesMessages property of the server is set incorrectly.

man/signal-cli.1.txt
src/main/java/org/asamk/signal/Main.java
src/main/java/org/asamk/signal/Manager.java

index 79df4d18fc907ea7df6fb1ca3475be7ccb83db64..a3ccf3475384687e084d2b732ba41ae1cedf44a5 100644 (file)
@@ -73,6 +73,11 @@ If this is the master device, other users can't send messages to this number any
 Use "updateAccount" to undo this.
 To remove a linked device, use "removeDevice" from the master device.
 
 Use "updateAccount" to undo this.
 To remove a linked device, use "removeDevice" from the master device.
 
+updateAccount
+~~~~~~~~
+Update the account attributes on the signal server.
+Can fix problems with receiving messages.
+
 link
 ~~~~
 Link to an existing device, instead of registering a new number.  This shows a
 link
 ~~~~
 Link to an existing device, instead of registering a new number.  This shows a
index ff590307d17f7aab23881b163f3959fb5e9b6af4..2377e12581dde1774d9dd726ffe257d4146505cb 100644 (file)
@@ -154,6 +154,22 @@ public class Main {
                         return 3;
                     }
                     break;
                         return 3;
                     }
                     break;
+                case "updateAccount":
+                    if (dBusConn != null) {
+                        System.err.println("updateAccount is not yet implemented via dbus");
+                        return 1;
+                    }
+                    if (!m.isRegistered()) {
+                        System.err.println("User is not registered.");
+                        return 1;
+                    }
+                    try {
+                        m.updateAccountAttributes();
+                    } catch (IOException e) {
+                        System.err.println("UpdateAccount error: " + e.getMessage());
+                        return 3;
+                    }
+                    break;
                 case "verify":
                     if (dBusConn != null) {
                         System.err.println("verify is not yet implemented via dbus");
                 case "verify":
                     if (dBusConn != null) {
                         System.err.println("verify is not yet implemented via dbus");
@@ -698,6 +714,9 @@ public class Main {
         Subparser parserUnregister = subparsers.addParser("unregister");
         parserUnregister.help("Unregister the current device from the signal server.");
 
         Subparser parserUnregister = subparsers.addParser("unregister");
         parserUnregister.help("Unregister the current device from the signal server.");
 
+        Subparser parserUpdateAccount = subparsers.addParser("updateAccount");
+        parserUpdateAccount.help("Update the account attributes on the signal server.");
+
         Subparser parserVerify = subparsers.addParser("verify");
         parserVerify.addArgument("verificationCode")
                 .help("The verification code you received via sms or voice call.");
         Subparser parserVerify = subparsers.addParser("verify");
         parserVerify.addArgument("verificationCode")
                 .help("The verification code you received via sms or voice call.");
index a6dfcae5a7edf779c6421c209bc512c8c6432e98..d51e8b575ef2f884f60ebea2c9b1439040863b35 100644 (file)
@@ -356,6 +356,10 @@ class Manager implements Signal {
         save();
     }
 
         save();
     }
 
+    public void updateAccountAttributes() throws IOException {
+        accountManager.setAccountAttributes(signalingKey, signalProtocolStore.getLocalRegistrationId(), false, true);
+    }
+
     public void unregister() throws IOException {
         // When setting an empty GCM id, the Signal-Server also sets the fetchesMessages property to false.
         // If this is the master device, other users can't send messages to this number anymore.
     public void unregister() throws IOException {
         // When setting an empty GCM id, the Signal-Server also sets the fetchesMessages property to false.
         // If this is the master device, other users can't send messages to this number anymore.