X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/d27a12a6cfcf9afca362a8d359ee808b1507e0b3..fd92a96e1a1d8b5464772667579ee3387a46453b:/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 7519950e..0c617646 100644 --- a/lib/src/main/java/org/asamk/signal/manager/ProvisioningManagerImpl.java +++ b/lib/src/main/java/org/asamk/signal/manager/ProvisioningManagerImpl.java @@ -136,6 +136,7 @@ class ProvisioningManagerImpl implements ProvisioningManager { account = SignalAccount.createOrUpdateLinkedAccount(pathConfig.dataPath(), accountPath, number, + serviceEnvironmentConfig.getType(), aci, pni, password, @@ -149,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; @@ -205,14 +205,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) {