Add unregister command

Fixes #57
This commit is contained in:
AsamK 2017-02-18 12:01:55 +01:00
parent 92c1f16799
commit be963ed49b
3 changed files with 33 additions and 0 deletions

View file

@ -66,6 +66,13 @@ Verify the number using the code received via SMS or voice.
VERIFICATIONCODE:: VERIFICATIONCODE::
The verification code. 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
~~~~ ~~~~
Link to an existing device, instead of registering a new number. This shows a Link to an existing device, instead of registering a new number. This shows a

View file

@ -138,6 +138,22 @@ public class Main {
return 3; return 3;
} }
break; 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": case "verify":
if (dBusConn != null) { if (dBusConn != null) {
System.err.println("verify is not yet implemented via dbus"); 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.") .help("The verification should be done over voice, not sms.")
.action(Arguments.storeTrue()); .action(Arguments.storeTrue());
Subparser parserUnregister = subparsers.addParser("unregister");
parserUnregister.help("Unregister the current device from the signal server.");
Subparser parserVerify = subparsers.addParser("verify"); Subparser parserVerify = subparsers.addParser("verify");
parserVerify.addArgument("verificationCode") parserVerify.addArgument("verificationCode")
.help("The verification code you received via sms or voice call."); .help("The verification code you received via sms or voice call.");

View file

@ -356,6 +356,13 @@ class Manager implements Signal {
save(); 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.<String>absent());
}
public URI getDeviceLinkUri() throws TimeoutException, IOException { public URI getDeviceLinkUri() throws TimeoutException, IOException {
password = Util.getSecret(18); password = Util.getSecret(18);