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
|
@JvmStatic
|
||||||
fun enqueueIfNecessary() {
|
fun enqueueIfNecessary() {
|
||||||
if (SignalStore.svr().hasPin()) {
|
if (SignalStore.svr().hasPin() && SignalStore.account().isRegistered) {
|
||||||
val lastTimestamp = SignalStore.svr().lastRefreshAuthTimestamp
|
val lastTimestamp = SignalStore.svr().lastRefreshAuthTimestamp
|
||||||
if (lastTimestamp + FREQUENCY.inWholeMilliseconds < System.currentTimeMillis() || lastTimestamp > System.currentTimeMillis()) {
|
if (lastTimestamp + FREQUENCY.inWholeMilliseconds < System.currentTimeMillis() || lastTimestamp > System.currentTimeMillis()) {
|
||||||
ApplicationDependencies.getJobManager().add(RefreshSvrCredentialsJob())
|
ApplicationDependencies.getJobManager().add(RefreshSvrCredentialsJob())
|
||||||
|
@ -40,6 +40,7 @@ class RefreshSvrCredentialsJob private constructor(parameters: Parameters) : Bas
|
||||||
.setQueue("RefreshKbsCredentials")
|
.setQueue("RefreshKbsCredentials")
|
||||||
.addConstraint(NetworkConstraint.KEY)
|
.addConstraint(NetworkConstraint.KEY)
|
||||||
.setMaxInstancesForQueue(2)
|
.setMaxInstancesForQueue(2)
|
||||||
|
.setMaxAttempts(3)
|
||||||
.setLifespan(1.days.inWholeMilliseconds)
|
.setLifespan(1.days.inWholeMilliseconds)
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
|
@ -49,6 +50,11 @@ class RefreshSvrCredentialsJob private constructor(parameters: Parameters) : Bas
|
||||||
override fun getFactoryKey(): String = KEY
|
override fun getFactoryKey(): String = KEY
|
||||||
|
|
||||||
override fun onRun() {
|
override fun onRun() {
|
||||||
|
if (!SignalStore.account().isRegistered) {
|
||||||
|
Log.w(TAG, "Not registered! Skipping.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
SvrRepository.refreshAndStoreAuthorization()
|
SvrRepository.refreshAndStoreAuthorization()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue