2020-04-07 17:19:53 +00:00
|
|
|
package org.thoughtcrime.securesms.registration;
|
|
|
|
|
2020-12-04 23:31:58 +00:00
|
|
|
import org.signal.core.util.logging.Log;
|
2020-04-24 22:37:12 +00:00
|
|
|
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
|
|
|
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
2021-04-26 16:04:06 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.StorageSyncJob;
|
2020-04-07 17:19:53 +00:00
|
|
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
|
|
|
|
|
|
|
public final class RegistrationUtil {
|
|
|
|
|
|
|
|
private static final String TAG = Log.tag(RegistrationUtil.class);
|
|
|
|
|
|
|
|
private RegistrationUtil() {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* There's several events where a registration may or may not be considered complete based on what
|
|
|
|
* path a user has taken. This will only truly mark registration as complete if all of the
|
|
|
|
* requirements are met.
|
|
|
|
*/
|
2023-02-27 15:06:35 +00:00
|
|
|
public static void maybeMarkRegistrationComplete() {
|
2020-07-13 22:52:30 +00:00
|
|
|
if (!SignalStore.registrationValues().isRegistrationComplete() &&
|
2021-11-17 20:08:28 +00:00
|
|
|
SignalStore.account().isRegistered() &&
|
2020-07-13 22:52:30 +00:00
|
|
|
!Recipient.self().getProfileName().isEmpty() &&
|
|
|
|
(SignalStore.kbsValues().hasPin() || SignalStore.kbsValues().hasOptedOut()))
|
|
|
|
{
|
2020-04-07 17:19:53 +00:00
|
|
|
Log.i(TAG, "Marking registration completed.", new Throwable());
|
|
|
|
SignalStore.registrationValues().setRegistrationComplete();
|
2021-04-26 16:04:06 +00:00
|
|
|
ApplicationDependencies.getJobManager().startChain(new StorageSyncJob())
|
2020-04-24 22:37:12 +00:00
|
|
|
.then(new DirectoryRefreshJob(false))
|
|
|
|
.enqueue();
|
2020-04-23 16:03:23 +00:00
|
|
|
} else if (!SignalStore.registrationValues().isRegistrationComplete()) {
|
|
|
|
Log.i(TAG, "Registration is not yet complete.", new Throwable());
|
2020-04-07 17:19:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|