]> nmode's Git Repositories - signal-cli/commitdiff
Add --delete-account argument to completely delete an account
authorAsamK <asamk@gmx.de>
Sun, 2 May 2021 22:03:31 +0000 (00:03 +0200)
committerAsamK <asamk@gmx.de>
Mon, 3 May 2021 16:43:45 +0000 (18:43 +0200)
lib/src/main/java/org/asamk/signal/manager/Manager.java
man/signal-cli.1.adoc
src/main/java/org/asamk/signal/commands/UnregisterCommand.java

index e39394800700eb6dd8758d499f67bba10c6a6fa4..7f0c48dc232b2ebc9e598e3517876f5acc76cb22 100644 (file)
@@ -406,6 +406,11 @@ public class Manager implements Closeable {
         // If this is the master device, other users can't send messages to this number anymore.
         // If this is a linked device, other users can still send messages, but this device doesn't receive them anymore.
         accountManager.setGcmId(Optional.absent());
+
+        account.setRegistered(false);
+    }
+
+    public void deleteAccount() throws IOException {
         accountManager.deleteAccount();
 
         account.setRegistered(false);
index f6145385ee2362672bc317d6d6e6548049852f09..565909a5811371401d7f0e1030fb81d057b5df3a 100644 (file)
@@ -92,6 +92,12 @@ 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.
 
+*--delete-account*::
+Delete account completely from server. Cannot be undone without loss. You will
+have to be readded to each group.
+
+CAUTION: Only delete your account if you won't use this number again!
+
 === updateAccount
 
 Update the account attributes on the signal server.
index 1846eba17b980104986b5b5349a95461c7e6c41b..72df842e34b69a3fa05b4e7ff1ef2320e3805c85 100644 (file)
@@ -1,5 +1,6 @@
 package org.asamk.signal.commands;
 
+import net.sourceforge.argparse4j.impl.Arguments;
 import net.sourceforge.argparse4j.inf.Namespace;
 import net.sourceforge.argparse4j.inf.Subparser;
 
@@ -14,13 +15,21 @@ public class UnregisterCommand implements LocalCommand {
     @Override
     public void attachToSubparser(final Subparser subparser) {
         subparser.help("Unregister the current device from the signal server.");
+        subparser.addArgument("--delete-account")
+                .help("Delete account completely from server. CAUTION: Only do this if you won't use this number again!")
+                .action(Arguments.storeTrue());
     }
 
     @Override
     public void handleCommand(final Namespace ns, final Manager m) throws CommandException {
         try {
-            m.unregister();
+            if (ns.getBoolean("delete_account")) {
+                m.deleteAccount();
+            } else {
+                m.unregister();
+            }
         } catch (IOException e) {
+            e.printStackTrace();
             throw new IOErrorException("Unregister error: " + e.getMessage());
         }
     }