From: AsamK Date: Sat, 18 Feb 2017 11:01:55 +0000 (+0100) Subject: Add unregister command X-Git-Tag: v0.5.5~2 X-Git-Url: https://git.nmode.ca/signal-cli/commitdiff_plain/be963ed49b6b32ab90707c453f8ce2c85b72e428 Add unregister command Fixes #57 --- diff --git a/man/signal-cli.1.txt b/man/signal-cli.1.txt index ddf855fd..79df4d18 100644 --- a/man/signal-cli.1.txt +++ b/man/signal-cli.1.txt @@ -66,6 +66,13 @@ Verify the number using the code received via SMS or voice. VERIFICATIONCODE:: The verification code. +unregister +~~~~~~~~ +Disable push support for this device, i.e. this device won't receive any more messages. +If this is the master device, other users can't send messages to this number anymore. +Use "updateAccount" to undo this. +To remove a linked device, use "removeDevice" from the master device. + link ~~~~ Link to an existing device, instead of registering a new number. This shows a diff --git a/src/main/java/org/asamk/signal/Main.java b/src/main/java/org/asamk/signal/Main.java index 633ef469..ff590307 100644 --- a/src/main/java/org/asamk/signal/Main.java +++ b/src/main/java/org/asamk/signal/Main.java @@ -138,6 +138,22 @@ public class Main { return 3; } break; + case "unregister": + if (dBusConn != null) { + System.err.println("unregister is not yet implemented via dbus"); + return 1; + } + if (!m.isRegistered()) { + System.err.println("User is not registered."); + return 1; + } + try { + m.unregister(); + } catch (IOException e) { + System.err.println("Unregister error: " + e.getMessage()); + return 3; + } + break; case "verify": if (dBusConn != null) { System.err.println("verify is not yet implemented via dbus"); @@ -679,6 +695,9 @@ public class Main { .help("The verification should be done over voice, not sms.") .action(Arguments.storeTrue()); + Subparser parserUnregister = subparsers.addParser("unregister"); + parserUnregister.help("Unregister the current device from the signal server."); + Subparser parserVerify = subparsers.addParser("verify"); parserVerify.addArgument("verificationCode") .help("The verification code you received via sms or voice call."); diff --git a/src/main/java/org/asamk/signal/Manager.java b/src/main/java/org/asamk/signal/Manager.java index ab1f1191..a6dfcae5 100644 --- a/src/main/java/org/asamk/signal/Manager.java +++ b/src/main/java/org/asamk/signal/Manager.java @@ -356,6 +356,13 @@ class Manager implements Signal { save(); } + 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. + // If this is a linked device, other users can still send messages, but this device doesn't receive them anymore. + accountManager.setGcmId(Optional.absent()); + } + public URI getDeviceLinkUri() throws TimeoutException, IOException { password = Util.getSecret(18);