X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/f3b2df62dae51496c8c5c9c85ac5a3951ea27978..c487929bcd505a76b4ee445a0765079184865e8b:/lib/src/main/java/org/asamk/signal/manager/ProvisioningManagerImpl.java diff --git a/lib/src/main/java/org/asamk/signal/manager/ProvisioningManagerImpl.java b/lib/src/main/java/org/asamk/signal/manager/ProvisioningManagerImpl.java index 75163555..e405f54c 100644 --- a/lib/src/main/java/org/asamk/signal/manager/ProvisioningManagerImpl.java +++ b/lib/src/main/java/org/asamk/signal/manager/ProvisioningManagerImpl.java @@ -23,10 +23,10 @@ import org.asamk.signal.manager.storage.SignalAccount; import org.asamk.signal.manager.storage.accounts.AccountsStore; import org.asamk.signal.manager.storage.identities.TrustNewIdentity; import org.asamk.signal.manager.util.KeyUtils; +import org.signal.libsignal.protocol.IdentityKeyPair; +import org.signal.libsignal.protocol.util.KeyHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.whispersystems.libsignal.IdentityKeyPair; -import org.whispersystems.libsignal.util.KeyHelper; import org.whispersystems.signalservice.api.SignalServiceAccountManager; import org.whispersystems.signalservice.api.groupsv2.ClientZkOperations; import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations; @@ -74,7 +74,8 @@ class ProvisioningManagerImpl implements ProvisioningManager { password = KeyUtils.createPassword(); GroupsV2Operations groupsV2Operations; try { - groupsV2Operations = new GroupsV2Operations(ClientZkOperations.create(serviceEnvironmentConfig.getSignalServiceConfiguration())); + groupsV2Operations = new GroupsV2Operations(ClientZkOperations.create(serviceEnvironmentConfig.getSignalServiceConfiguration()), + ServiceConfig.GROUP_MAX_SIZE); } catch (Throwable ignored) { groupsV2Operations = null; } @@ -135,6 +136,7 @@ class ProvisioningManagerImpl implements ProvisioningManager { account = SignalAccount.createOrUpdateLinkedAccount(pathConfig.dataPath(), accountPath, number, + serviceEnvironmentConfig.getType(), aci, pni, password, @@ -148,10 +150,9 @@ class ProvisioningManagerImpl implements ProvisioningManager { ManagerImpl m = null; try { - final var accountPathFinal = accountPath; m = new ManagerImpl(account, pathConfig, - (newNumber, newAci) -> accountsStore.updateAccount(accountPathFinal, newNumber, newAci), + new AccountFileUpdaterImpl(accountsStore, accountPath), serviceEnvironmentConfig, userAgent); account = null; @@ -160,7 +161,7 @@ class ProvisioningManagerImpl implements ProvisioningManager { try { m.refreshPreKeys(); } catch (Exception e) { - logger.error("Failed to refresh pre keys."); + logger.error("Failed to refresh pre keys.", e); } logger.debug("Requesting sync data"); @@ -168,7 +169,8 @@ class ProvisioningManagerImpl implements ProvisioningManager { m.requestAllSyncData(); } catch (Exception e) { logger.error( - "Failed to request sync messages from linked device, data can be requested again with `sendSyncRequest`."); + "Failed to request sync messages from linked device, data can be requested again with `sendSyncRequest`.", + e); } if (newManagerListener != null) { @@ -204,14 +206,21 @@ class ProvisioningManagerImpl implements ProvisioningManager { } try (signalAccount) { - if (signalAccount.isMasterDevice()) { - logger.debug("Account is a master device."); + if (signalAccount.isPrimaryDevice()) { + logger.debug("Account is a primary device."); + return false; + } + if (signalAccount.isRegistered() + && signalAccount.getServiceEnvironment() != null + && signalAccount.getServiceEnvironment() != serviceEnvironmentConfig.getType()) { + logger.debug("Account is registered in another environment: {}.", + signalAccount.getServiceEnvironment()); return false; } final var m = new ManagerImpl(signalAccount, pathConfig, - (newNumber, newAci) -> accountsStore.updateAccount(accountPath, newNumber, newAci), + new AccountFileUpdaterImpl(accountsStore, accountPath), serviceEnvironmentConfig, userAgent); try (m) {