]> nmode's Git Repositories - signal-cli/commitdiff
Manager : removeLinkedDevices updates isMultiDevice and saves the account
authorVincent Olivier <vincent@up4.com>
Tue, 20 Nov 2018 22:47:10 +0000 (17:47 -0500)
committerAsamK <asamk@gmx.de>
Wed, 21 Nov 2018 10:04:10 +0000 (11:04 +0100)
Manager : addDevice, getLinkedDevices save the account

SignalAccount : save/load isMultiDevice
SignalAccount : save profileKey
SignalAccount : registrationLockPin doesn't automagically becomes the "null" string, and stays null if null

src/main/java/org/asamk/signal/manager/Manager.java
src/main/java/org/asamk/signal/storage/SignalAccount.java

index f8870a72d0cbbfacda3681da04435d3f76a51388..cb49d4630218d467d146a72a2e5dfe9aaf7e3b0a 100644 (file)
@@ -248,11 +248,15 @@ public class Manager implements Signal {
     public List<DeviceInfo> getLinkedDevices() throws IOException {
         List<DeviceInfo> devices = accountManager.getDevices();
         account.setMultiDevice(devices.size() > 1);
+        account.save();
         return devices;
     }
 
     public void removeLinkedDevices(int deviceId) throws IOException {
         accountManager.removeDevice(deviceId);
+        List<DeviceInfo> devices = accountManager.getDevices();
+        account.setMultiDevice(devices.size() > 1);
+        account.save();
     }
 
     public void addDeviceLink(URI linkUri) throws IOException, InvalidKeyException {
@@ -267,6 +271,7 @@ public class Manager implements Signal {
 
         accountManager.addDevice(deviceIdentifier, deviceKey, identityKeyPair, Optional.of(account.getProfileKey()), verificationCode);
         account.setMultiDevice(true);
+        account.save();
     }
 
     private List<PreKeyRecord> generatePreKeys() {
index cdc3efa5cf667bf3d0a84622b4e6d662c156f959..4378d052a64871850b6c52c4d4a30fdb7f91b1e9 100644 (file)
@@ -135,10 +135,11 @@ public class SignalAccount {
         if (node != null) {
             deviceId = node.asInt();
         }
+        if (rootNode.has("isMultiDevice")) isMultiDevice = Util.getNotNullNode(rootNode, "isMultiDevice").asBoolean();
         username = Util.getNotNullNode(rootNode, "username").asText();
         password = Util.getNotNullNode(rootNode, "password").asText();
         JsonNode pinNode = rootNode.get("registrationLockPin");
-        registrationLockPin = pinNode == null ? null : pinNode.asText();
+        registrationLockPin = pinNode == null || pinNode.isNull() ? null : pinNode.asText();
         if (rootNode.has("signalingKey")) {
             signalingKey = Util.getNotNullNode(rootNode, "signalingKey").asText();
         }
@@ -189,11 +190,13 @@ public class SignalAccount {
         ObjectNode rootNode = jsonProcessor.createObjectNode();
         rootNode.put("username", username)
                 .put("deviceId", deviceId)
+                .put("isMultiDevice", isMultiDevice)
                 .put("password", password)
                 .put("registrationLockPin", registrationLockPin)
                 .put("signalingKey", signalingKey)
                 .put("preKeyIdOffset", preKeyIdOffset)
                 .put("nextSignedPreKeyId", nextSignedPreKeyId)
+                .put("profileKey", Base64.encodeBytes(profileKey))
                 .put("registered", registered)
                 .putPOJO("axolotlStore", signalProtocolStore)
                 .putPOJO("groupStore", groupStore)