Handle profile key changes consistently.

This commit is contained in:
Greyson Parrelli
2022-03-10 16:52:01 -05:00
committed by Cody Henthorne
parent 9281bcdd7d
commit 803f94012a
9 changed files with 60 additions and 28 deletions

View File

@@ -7,6 +7,7 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.jobmanager.Data;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
import org.thoughtcrime.securesms.jobs.RefreshOwnProfileJob;
import org.thoughtcrime.securesms.jobs.StorageForcePushJob;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
@@ -40,8 +41,10 @@ public final class PinOptOutMigration extends MigrationJob {
Log.w(TAG, "Discovered a legacy opt-out user! Resetting the state.");
SignalStore.kbsValues().optOut();
ApplicationDependencies.getJobManager().add(new RefreshAttributesJob());
ApplicationDependencies.getJobManager().add(new StorageForcePushJob());
ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob())
.then(new RefreshOwnProfileJob())
.then(new StorageForcePushJob())
.enqueue();
} else if (SignalStore.kbsValues().hasOptedOut()) {
Log.i(TAG, "Discovered an opt-out user, but they're already in a good state. No action required.");
} else {

View File

@@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.jobmanager.JobManager;
import org.thoughtcrime.securesms.jobs.MultiDeviceKeysUpdateJob;
import org.thoughtcrime.securesms.jobs.MultiDeviceStorageSyncRequestJob;
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
import org.thoughtcrime.securesms.jobs.RefreshOwnProfileJob;
import org.thoughtcrime.securesms.jobs.StorageForcePushJob;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
@@ -50,7 +51,7 @@ public class StorageCapabilityMigrationJob extends MigrationJob {
public void performMigration() {
JobManager jobManager = ApplicationDependencies.getJobManager();
jobManager.add(new RefreshAttributesJob());
jobManager.startChain(new RefreshAttributesJob()).then(new RefreshOwnProfileJob()).enqueue();
if (TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Multi-device.");