Add command to update account attributes

This can fix problems with receiving messages, if for some reason, the
fetchesMessages property of the server is set incorrectly.
This commit is contained in:
AsamK 2017-02-18 12:03:17 +01:00
parent be963ed49b
commit 0a68303ca4
3 changed files with 28 additions and 0 deletions

View 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. Use "updateAccount" to undo this.
To remove a linked device, use "removeDevice" from the master device. 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
~~~~ ~~~~
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

@ -154,6 +154,22 @@ public class Main {
return 3; return 3;
} }
break; 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": 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");
@ -698,6 +714,9 @@ public class Main {
Subparser parserUnregister = subparsers.addParser("unregister"); Subparser parserUnregister = subparsers.addParser("unregister");
parserUnregister.help("Unregister the current device from the signal server."); 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"); 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,10 @@ class Manager implements Signal {
save(); save();
} }
public void updateAccountAttributes() throws IOException {
accountManager.setAccountAttributes(signalingKey, signalProtocolStore.getLocalRegistrationId(), false, true);
}
public void unregister() throws IOException { public void unregister() throws IOException {
// When setting an empty GCM id, the Signal-Server also sets the fetchesMessages property to false. // 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 the master device, other users can't send messages to this number anymore.