From 6cb8c7a8a9eecea6508b9958dec573deb92deb25 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Thu, 23 Feb 2023 16:51:25 -0500 Subject: [PATCH] Ensure attributes are updated with latest properties. --- .../securesms/jobs/RefreshKbsCredentialsJob.kt | 12 +++++++----- .../securesms/migrations/ApplicationMigrations.java | 8 +++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshKbsCredentialsJob.kt b/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshKbsCredentialsJob.kt index a05f1e47b0..04265b3e55 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshKbsCredentialsJob.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshKbsCredentialsJob.kt @@ -25,11 +25,13 @@ class RefreshKbsCredentialsJob private constructor(parameters: Parameters) : Bas @JvmStatic fun enqueueIfNecessary() { - val lastTimestamp = SignalStore.kbsValues().lastRefreshAuthTimestamp - if (lastTimestamp + FREQUENCY.inWholeMilliseconds < System.currentTimeMillis() || lastTimestamp > System.currentTimeMillis()) { - ApplicationDependencies.getJobManager().add(RefreshKbsCredentialsJob()) - } else { - Log.d(TAG, "Do not need to refresh credentials. Last refresh: $lastTimestamp") + if (SignalStore.kbsValues().hasPin()) { + val lastTimestamp = SignalStore.kbsValues().lastRefreshAuthTimestamp + if (lastTimestamp + FREQUENCY.inWholeMilliseconds < System.currentTimeMillis() || lastTimestamp > System.currentTimeMillis()) { + ApplicationDependencies.getJobManager().add(RefreshKbsCredentialsJob()) + } else { + Log.d(TAG, "Do not need to refresh credentials. Last refresh: $lastTimestamp") + } } } } diff --git a/app/src/main/java/org/thoughtcrime/securesms/migrations/ApplicationMigrations.java b/app/src/main/java/org/thoughtcrime/securesms/migrations/ApplicationMigrations.java index e033b2532b..5d66ab17a0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/migrations/ApplicationMigrations.java +++ b/app/src/main/java/org/thoughtcrime/securesms/migrations/ApplicationMigrations.java @@ -12,6 +12,7 @@ import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.signal.core.util.logging.Log; import org.thoughtcrime.securesms.jobmanager.JobManager; +import org.thoughtcrime.securesms.jobs.RefreshAttributesJob; import org.thoughtcrime.securesms.keyvalue.SignalStore; import org.thoughtcrime.securesms.stickers.BlessedPacks; import org.thoughtcrime.securesms.util.TextSecurePreferences; @@ -120,9 +121,10 @@ public class ApplicationMigrations { static final int REBUILD_MESSAGE_FTS_INDEX_2 = 76; static final int GLIDE_CACHE_CLEAR = 77; static final int SYSTEM_NAME_RESYNC = 78; + static final int RECOVERY_PASSWORD_SYNC = 79; } - public static final int CURRENT_VERSION = 78; + public static final int CURRENT_VERSION = 79; /** * This *must* be called after the {@link JobManager} has been instantiated, but *before* the call @@ -536,6 +538,10 @@ public class ApplicationMigrations { jobs.put(Version.SYSTEM_NAME_RESYNC, new StorageServiceSystemNameMigrationJob()); } + if (lastSeenVersion < Version.RECOVERY_PASSWORD_SYNC) { + jobs.put(Version.RECOVERY_PASSWORD_SYNC, new AttributesMigrationJob()); + } + return jobs; }