From 0a68303ca448f69a5655beb23f4213187dbce0b4 Mon Sep 17 00:00:00 2001 From: AsamK Date: Sat, 18 Feb 2017 12:03:17 +0100 Subject: [PATCH] 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. --- man/signal-cli.1.txt | 5 +++++ src/main/java/org/asamk/signal/Main.java | 19 +++++++++++++++++++ src/main/java/org/asamk/signal/Manager.java | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/man/signal-cli.1.txt b/man/signal-cli.1.txt index 79df4d18..a3ccf347 100644 --- a/man/signal-cli.1.txt +++ b/man/signal-cli.1.txt @@ -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. +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 diff --git a/src/main/java/org/asamk/signal/Main.java b/src/main/java/org/asamk/signal/Main.java index ff590307..2377e125 100644 --- a/src/main/java/org/asamk/signal/Main.java +++ b/src/main/java/org/asamk/signal/Main.java @@ -154,6 +154,22 @@ public class Main { 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"); @@ -698,6 +714,9 @@ public class Main { 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."); diff --git a/src/main/java/org/asamk/signal/Manager.java b/src/main/java/org/asamk/signal/Manager.java index a6dfcae5..d51e8b57 100644 --- a/src/main/java/org/asamk/signal/Manager.java +++ b/src/main/java/org/asamk/signal/Manager.java @@ -356,6 +356,10 @@ class Manager implements Signal { 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. -- 2.50.1