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;
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;
}
account = SignalAccount.createOrUpdateLinkedAccount(pathConfig.dataPath(),
accountPath,
number,
+ serviceEnvironmentConfig.getType(),
aci,
pni,
password,
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;
}
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) {