Add migration for ensuring we set the latest pnp settings.
This commit is contained in:
parent
6097e6c305
commit
8797236b5a
3 changed files with 48 additions and 1 deletions
|
@ -63,6 +63,7 @@ import org.thoughtcrime.securesms.migrations.PinOptOutMigration;
|
|||
import org.thoughtcrime.securesms.migrations.PinReminderMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.PniAccountInitializationMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.PniMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.PnpLaunchMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.PreKeysSyncMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.ProfileMigrationJob;
|
||||
import org.thoughtcrime.securesms.migrations.ProfileSharingUpdateMigrationJob;
|
||||
|
@ -249,6 +250,7 @@ public final class JobManagerFactories {
|
|||
put(PinReminderMigrationJob.KEY, new PinReminderMigrationJob.Factory());
|
||||
put(PniAccountInitializationMigrationJob.KEY, new PniAccountInitializationMigrationJob.Factory());
|
||||
put(PniMigrationJob.KEY, new PniMigrationJob.Factory());
|
||||
put(PnpLaunchMigrationJob.KEY, new PnpLaunchMigrationJob.Factory());
|
||||
put(PreKeysSyncMigrationJob.KEY, new PreKeysSyncMigrationJob.Factory());
|
||||
put(ProfileMigrationJob.KEY, new ProfileMigrationJob.Factory());
|
||||
put(ProfileSharingUpdateMigrationJob.KEY, new ProfileSharingUpdateMigrationJob.Factory());
|
||||
|
|
|
@ -143,9 +143,10 @@ public class ApplicationMigrations {
|
|||
static final int SELF_REGISTERTED_STATE = 99;
|
||||
static final int SVR2_ENCLAVE_UPDATE = 100;
|
||||
static final int STORAGE_LOCAL_UNKNOWNS_FIX = 101;
|
||||
static final int PNP_LAUNCH = 102;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 101;
|
||||
public static final int CURRENT_VERSION = 102;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
|
@ -652,6 +653,10 @@ public class ApplicationMigrations {
|
|||
jobs.put(Version.STORAGE_LOCAL_UNKNOWNS_FIX, new StorageFixLocalUnknownMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.PNP_LAUNCH) {
|
||||
jobs.put(Version.PNP_LAUNCH, new PnpLaunchMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.ProfileUploadJob
|
||||
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob
|
||||
import java.lang.Exception
|
||||
|
||||
/**
|
||||
* Kicks off a chain of jobs to update the server with our latest PNP settings.
|
||||
*/
|
||||
internal class PnpLaunchMigrationJob(parameters: Parameters = Parameters.Builder().build()) : MigrationJob(parameters) {
|
||||
companion object {
|
||||
const val KEY = "PnpLaunchMigrationJob"
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
override fun performMigration() {
|
||||
ApplicationDependencies.getJobManager()
|
||||
.startChain(RefreshAttributesJob())
|
||||
.then(ProfileUploadJob())
|
||||
.enqueue()
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<PnpLaunchMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): PnpLaunchMigrationJob {
|
||||
return PnpLaunchMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue