Add support for system names on the ContactRecord.

This commit is contained in:
Greyson Parrelli
2022-09-28 14:09:44 -04:00
parent 6e5f28339d
commit 1999db97f2
11 changed files with 197 additions and 66 deletions

View File

@@ -108,9 +108,10 @@ public class ApplicationMigrations {
static final int REFRESH_PNI_REGISTRATION_ID = 64;
static final int KBS_MIGRATION_2 = 65;
static final int PNI_2 = 66;
static final int SYSTEM_NAME_SYNC = 67;
}
public static final int CURRENT_VERSION = 66;
public static final int CURRENT_VERSION = 67;
/**
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
@@ -476,6 +477,10 @@ public class ApplicationMigrations {
jobs.put(Version.PNI_2, new PniMigrationJob());
}
if (lastSeenVersion < Version.SYSTEM_NAME_SYNC) {
jobs.put(Version.SYSTEM_NAME_SYNC, new StorageServiceSystemNameMigrationJob());
}
return jobs;
}

View File

@@ -0,0 +1,56 @@
package org.thoughtcrime.securesms.migrations;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.jobmanager.Data;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobs.DownloadLatestEmojiDataJob;
import org.thoughtcrime.securesms.jobs.EmojiSearchIndexDownloadJob;
import org.thoughtcrime.securesms.storage.StorageSyncHelper;
/**
* Added for when we started syncing contact names in storage service.
* Rotates the storageId of every system contact and then schedules a storage sync.
*/
public final class StorageServiceSystemNameMigrationJob extends MigrationJob {
public static final String KEY = "StorageServiceSystemNameMigrationJob";
StorageServiceSystemNameMigrationJob() {
this(new Parameters.Builder().build());
}
private StorageServiceSystemNameMigrationJob(@NonNull Parameters parameters) {
super(parameters);
}
@Override
public boolean isUiBlocking() {
return false;
}
@Override
public @NonNull String getFactoryKey() {
return KEY;
}
@Override
public void performMigration() {
SignalDatabase.recipients().markAllSystemContactsNeedsSync();
StorageSyncHelper.scheduleSyncForDataChange();
}
@Override
boolean shouldRetry(@NonNull Exception e) {
return false;
}
public static class Factory implements Job.Factory<StorageServiceSystemNameMigrationJob> {
@Override
public @NonNull StorageServiceSystemNameMigrationJob create(@NonNull Parameters parameters, @NonNull Data data) {
return new StorageServiceSystemNameMigrationJob(parameters);
}
}
}