diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshSvrCredentialsJob.kt b/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshSvrCredentialsJob.kt index af8b89562e..397f1c9cab 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshSvrCredentialsJob.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/RefreshSvrCredentialsJob.kt @@ -24,7 +24,7 @@ class RefreshSvrCredentialsJob private constructor(parameters: Parameters) : Bas @JvmStatic fun enqueueIfNecessary() { - if (SignalStore.svr().hasPin()) { + if (SignalStore.svr().hasPin() && SignalStore.account().isRegistered) { val lastTimestamp = SignalStore.svr().lastRefreshAuthTimestamp if (lastTimestamp + FREQUENCY.inWholeMilliseconds < System.currentTimeMillis() || lastTimestamp > System.currentTimeMillis()) { ApplicationDependencies.getJobManager().add(RefreshSvrCredentialsJob()) @@ -40,6 +40,7 @@ class RefreshSvrCredentialsJob private constructor(parameters: Parameters) : Bas .setQueue("RefreshKbsCredentials") .addConstraint(NetworkConstraint.KEY) .setMaxInstancesForQueue(2) + .setMaxAttempts(3) .setLifespan(1.days.inWholeMilliseconds) .build() ) @@ -49,6 +50,11 @@ class RefreshSvrCredentialsJob private constructor(parameters: Parameters) : Bas override fun getFactoryKey(): String = KEY override fun onRun() { + if (!SignalStore.account().isRegistered) { + Log.w(TAG, "Not registered! Skipping.") + return + } + SvrRepository.refreshAndStoreAuthorization() }