That fuck shit the fascists are using
1package org.tm.archive.migrations;
2
3import androidx.annotation.NonNull;
4import androidx.annotation.Nullable;
5
6import org.signal.core.util.logging.Log;
7import org.tm.archive.dependencies.ApplicationDependencies;
8import org.tm.archive.jobmanager.Job;
9import org.tm.archive.jobs.RefreshAttributesJob;
10import org.tm.archive.jobs.RefreshOwnProfileJob;
11import org.tm.archive.jobs.StorageForcePushJob;
12import org.tm.archive.keyvalue.SignalStore;
13
14/**
15 * We changed some details of what it means to opt-out of a PIN. This ensures that users who went
16 * through the previous opt-out flow are now in the same state as users who went through the new
17 * opt-out flow.
18 */
19public final class PinOptOutMigration extends MigrationJob {
20
21 private static final String TAG = Log.tag(PinOptOutMigration.class);
22
23 public static final String KEY = "PinOptOutMigration";
24
25 PinOptOutMigration() {
26 this(new Parameters.Builder().build());
27 }
28
29 private PinOptOutMigration(@NonNull Parameters parameters) {
30 super(parameters);
31 }
32
33 @Override
34 boolean isUiBlocking() {
35 return false;
36 }
37
38 @Override
39 void performMigration() {
40 if (SignalStore.svr().hasOptedOut() && SignalStore.svr().hasPin()) {
41 Log.w(TAG, "Discovered a legacy opt-out user! Resetting the state.");
42
43 SignalStore.svr().optOut();
44 ApplicationDependencies.getJobManager().startChain(new RefreshAttributesJob())
45 .then(new RefreshOwnProfileJob())
46 .then(new StorageForcePushJob())
47 .enqueue();
48 } else if (SignalStore.svr().hasOptedOut()) {
49 Log.i(TAG, "Discovered an opt-out user, but they're already in a good state. No action required.");
50 } else {
51 Log.i(TAG, "Discovered a normal PIN user. No action required.");
52 }
53 }
54
55 @Override
56 boolean shouldRetry(@NonNull Exception e) {
57 return false;
58 }
59
60 @Override
61 public @NonNull String getFactoryKey() {
62 return KEY;
63 }
64
65 public static class Factory implements Job.Factory<PinOptOutMigration> {
66 @Override
67 public @NonNull PinOptOutMigration create(@NonNull Parameters parameters, @Nullable byte[] serializedData) {
68 return new PinOptOutMigration(parameters);
69 }
70 }
71}