mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
job related
This commit is contained in:
parent
c3552bfded
commit
4c1df33059
@ -4,7 +4,7 @@ import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
import java.util.Timer
|
||||
|
||||
import org.session.libsession.messaging.Configuration
|
||||
import org.session.libsession.messaging.MessagingConfiguration
|
||||
|
||||
import org.session.libsignal.libsignal.logging.Log
|
||||
import kotlin.concurrent.schedule
|
||||
@ -25,7 +25,7 @@ class JobQueue : JobDelegate {
|
||||
|
||||
fun addWithoutExecuting(job: Job) {
|
||||
job.id = System.currentTimeMillis().toString()
|
||||
Configuration.shared.storage.persist(job)
|
||||
MessagingConfiguration.shared.storage.persist(job)
|
||||
job.delegate = this
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ class JobQueue : JobDelegate {
|
||||
hasResumedPendingJobs = true
|
||||
val allJobTypes = listOf(AttachmentDownloadJob.collection, AttachmentDownloadJob.collection, MessageReceiveJob.collection, MessageSendJob.collection, NotifyPNServerJob.collection)
|
||||
allJobTypes.forEach { type ->
|
||||
val allPendingJobs = Configuration.shared.storage.getAllPendingJobs(type)
|
||||
val allPendingJobs = MessagingConfiguration.shared.storage.getAllPendingJobs(type)
|
||||
allPendingJobs.sortedBy { it.id }.forEach { job ->
|
||||
Log.i("Jobs", "Resuming pending job of type: ${job::class.simpleName}.")
|
||||
job.delegate = this
|
||||
@ -47,12 +47,12 @@ class JobQueue : JobDelegate {
|
||||
}
|
||||
|
||||
override fun handleJobSucceeded(job: Job) {
|
||||
Configuration.shared.storage.markJobAsSucceeded(job)
|
||||
MessagingConfiguration.shared.storage.markJobAsSucceeded(job)
|
||||
}
|
||||
|
||||
override fun handleJobFailed(job: Job, error: Exception) {
|
||||
job.failureCount += 1
|
||||
val storage = Configuration.shared.storage
|
||||
val storage = MessagingConfiguration.shared.storage
|
||||
if (storage.isJobCanceled(job)) { return Log.i("Jobs", "${job::class.simpleName} canceled.")}
|
||||
storage.persist(job)
|
||||
if (job.failureCount == job.maxFailureCount) {
|
||||
@ -69,7 +69,7 @@ class JobQueue : JobDelegate {
|
||||
|
||||
override fun handleJobFailedPermanently(job: Job, error: Exception) {
|
||||
job.failureCount += 1
|
||||
val storage = Configuration.shared.storage
|
||||
val storage = MessagingConfiguration.shared.storage
|
||||
storage.persist(job)
|
||||
storage.markJobAsFailed(job)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.session.libsession.messaging.jobs
|
||||
|
||||
class MessageReceiveJob : Job {
|
||||
class MessageReceiveJob(val data: ByteArray, val isBackgroundPoll: Boolean, val openGroupMessageServerID: Long? = null, val openGroupID: String? = null) : Job {
|
||||
override var delegate: JobDelegate? = null
|
||||
override var id: String? = null
|
||||
override var failureCount: Int = 0
|
||||
|
Loading…
Reference in New Issue
Block a user