Skip to content

Commit

Permalink
Ensure attributes are updated with latest properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody-signal committed Feb 23, 2023
1 parent ae3ff21 commit 6cb8c7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;
Expand Down Expand Up @@ -120,9 +121,10 @@ static final class Version {
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
Expand Down Expand Up @@ -536,6 +538,10 @@ private static LinkedHashMap<Integer, MigrationJob> getMigrationJobs(@NonNull Co
jobs.put(Version.SYSTEM_NAME_RESYNC, new StorageServiceSystemNameMigrationJob());
}

if (lastSeenVersion < Version.RECOVERY_PASSWORD_SYNC) {
jobs.put(Version.RECOVERY_PASSWORD_SYNC, new AttributesMigrationJob());
}

return jobs;
}

Expand Down

0 comments on commit 6cb8c7a

Please sign in to comment.