this.serviceEnvironmentConfig = ServiceConfig.getServiceEnvironmentConfig(this.serviceEnvironment, userAgent);
this.userAgent = userAgent;
this.trustNewIdentity = trustNewIdentity;
- this.accountsStore = new AccountsStore(pathConfig.dataPath());
+ this.accountsStore = new AccountsStore(pathConfig.dataPath(), serviceEnvironment, accountPath -> {
+ if (accountPath == null || !SignalAccount.accountFileExists(pathConfig.dataPath(), accountPath)) {
+ return null;
+ }
+
+ try {
+ return SignalAccount.load(pathConfig.dataPath(), accountPath, false, trustNewIdentity);
+ } catch (Exception e) {
+ return null;
+ }
+ });
}
- public Set<String> getAllLocalAccountNumbers() {
+ public Set<String> getAllLocalAccountNumbers() throws IOException {
return accountsStore.getAllNumbers();
}
- public MultiAccountManager initMultiAccountManager() {
+ public MultiAccountManager initMultiAccountManager() throws IOException {
final var managers = accountsStore.getAllAccounts().parallelStream().map(a -> {
try {
return initManager(a.number(), a.path());
} catch (NotRegisteredException | IOException | AccountCheckException e) {
logger.warn("Ignoring {}: {} ({})", a.number(), e.getMessage(), e.getClass().getSimpleName());
return null;
+ } catch (Throwable e) {
+ logger.error("Failed to load {}: {} ({})", a.number(), e.getMessage(), e.getClass().getSimpleName());
+ throw e;
}
}).filter(Objects::nonNull).toList();
final var manager = new ManagerImpl(account,
pathConfig,
- (newNumber, newAci) -> accountsStore.updateAccount(accountPath, newNumber, newAci),
+ new AccountFileUpdaterImpl(accountsStore, accountPath),
serviceEnvironmentConfig,
userAgent);
if (account.getServiceEnvironment() == null) {
account.setServiceEnvironment(serviceEnvironment);
+ accountsStore.updateAccount(accountPath, account.getNumber(), account.getAci());
}
return manager;
var aciIdentityKey = KeyUtils.generateIdentityKeyPair();
var pniIdentityKey = KeyUtils.generateIdentityKeyPair();
var registrationId = KeyHelper.generateRegistrationId(false);
+ var pniRegistrationId = KeyHelper.generateRegistrationId(false);
var profileKey = KeyUtils.createProfileKey();
var account = SignalAccount.create(pathConfig.dataPath(),
aciIdentityKey,
pniIdentityKey,
registrationId,
+ pniRegistrationId,
profileKey,
trustNewIdentity);
serviceEnvironmentConfig,
userAgent,
newManagerListener,
- (newNumber, newAci) -> accountsStore.updateAccount(newAccountPath, newNumber, newAci));
+ new AccountFileUpdaterImpl(accountsStore, newAccountPath));
}
var account = SignalAccount.load(pathConfig.dataPath(), accountPath, true, trustNewIdentity);
serviceEnvironmentConfig,
userAgent,
newManagerListener,
- (newNumber, newAci) -> accountsStore.updateAccount(accountPath, newNumber, newAci));
+ new AccountFileUpdaterImpl(accountsStore, accountPath));
}
}