Limit RefreshSvrCredentialsJob to registered users.
This commit is contained in:
parent
148cff1b48
commit
2abf30e94b
1 changed files with 7 additions and 1 deletions
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue