import org.whispersystems.signalservice.api.groupsv2.ClientZkOperations;
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
import org.whispersystems.signalservice.api.push.ACI;
+import org.whispersystems.signalservice.api.push.PNI;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.internal.ServiceResponse;
import org.whispersystems.signalservice.internal.push.VerifyAccountResponse;
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;
}
this.accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.getSignalServiceConfiguration(),
new DynamicCredentialsProvider(
// Using empty UUID, because registering doesn't work otherwise
- null, account.getNumber(), account.getPassword(), SignalServiceAddress.DEFAULT_DEVICE_ID),
+ null, null, account.getNumber(), account.getPassword(), SignalServiceAddress.DEFAULT_DEVICE_ID),
userAgent,
groupsV2Operations,
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
@Override
public void register(boolean voiceVerification, String captcha) throws IOException, CaptchaRequiredException {
+ if (account.isRegistered()
+ && account.getServiceEnvironment() != null
+ && account.getServiceEnvironment() != serviceEnvironmentConfig.getType()) {
+ throw new IOException("Account is registered in another environment: " + account.getServiceEnvironment());
+ }
+
if (account.getAci() != null && attemptReactivateAccount()) {
return;
}
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
final var aci = ACI.parseOrNull(response.getUuid());
- account.finishRegistration(aci, masterKey, pin);
+ final var pni = PNI.parseOrNull(response.getPni());
+ account.finishRegistration(aci, pni, masterKey, pin);
accountFileUpdater.updateAccountIdentifiers(account.getNumber(), aci);
ManagerImpl m = null;
}
}
+ @Override
+ public void deleteLocalAccountData() throws IOException {
+ account.deleteAccountData();
+ accountFileUpdater.removeAccount();
+ account = null;
+ }
+
+ @Override
+ public boolean isRegistered() {
+ return account.isRegistered();
+ }
+
private boolean attemptReactivateAccount() {
try {
final var accountManager = new SignalServiceAccountManager(serviceEnvironmentConfig.getSignalServiceConfiguration(),
userAgent,
null,
ServiceConfig.AUTOMATIC_NETWORK_RETRY);
- accountManager.setAccountAttributes(account.getEncryptedDeviceName(),
- null,
+ accountManager.setAccountAttributes(null,
account.getLocalRegistrationId(),
true,
null,
account.getSelfUnidentifiedAccessKey(),
account.isUnrestrictedUnidentifiedAccess(),
capabilities,
- account.isDiscoverableByPhoneNumber());
+ account.isDiscoverableByPhoneNumber(),
+ account.getEncryptedDeviceName());
account.setRegistered(true);
logger.info("Reactivated existing account, verify is not necessary.");
if (newManagerListener != null) {