mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Fix payments spinning forever.
This commit is contained in:
committed by
Greyson Parrelli
parent
6a21106347
commit
b83080e2d7
@@ -137,9 +137,10 @@ public class ApplicationMigrations {
|
||||
static final int EMOJI_SEARCH_INDEX_CHECK = 93;
|
||||
static final int IDENTITY_FIX = 94;
|
||||
static final int COPY_USERNAME_TO_SIGNAL_STORE = 95;
|
||||
static final int RECHECK_PAYMENTS = 96;
|
||||
}
|
||||
|
||||
public static final int CURRENT_VERSION = 95;
|
||||
public static final int CURRENT_VERSION = 96;
|
||||
|
||||
/**
|
||||
* This *must* be called after the {@link JobManager} has been instantiated, but *before* the call
|
||||
@@ -622,6 +623,10 @@ public class ApplicationMigrations {
|
||||
jobs.put(Version.COPY_USERNAME_TO_SIGNAL_STORE, new CopyUsernameToSignalStoreMigrationJob());
|
||||
}
|
||||
|
||||
if (lastSeenVersion < Version.RECHECK_PAYMENTS) {
|
||||
jobs.put(Version.RECHECK_PAYMENTS, new RecheckPaymentsMigrationJob());
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.thoughtcrime.securesms.migrations
|
||||
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobs.PaymentLedgerUpdateJob
|
||||
import org.thoughtcrime.securesms.jobs.PaymentTransactionCheckJob
|
||||
|
||||
/**
|
||||
* Migration to recheck incoming payments that may have been missed due to db race.
|
||||
*/
|
||||
internal class RecheckPaymentsMigrationJob(
|
||||
parameters: Parameters = Parameters.Builder().build()
|
||||
) : MigrationJob(parameters) {
|
||||
|
||||
companion object {
|
||||
const val KEY = "RecheckPaymentsMigrationJob"
|
||||
|
||||
val TAG = Log.tag(RecheckPaymentsMigrationJob::class.java)
|
||||
}
|
||||
|
||||
override fun getFactoryKey(): String = KEY
|
||||
|
||||
override fun isUiBlocking(): Boolean = false
|
||||
|
||||
@Suppress("UsePropertyAccessSyntax")
|
||||
override fun performMigration() {
|
||||
val jobs: MutableList<Job> = SignalDatabase
|
||||
.payments
|
||||
.getSubmittedIncomingPayments()
|
||||
.filterNotNull()
|
||||
.map { PaymentTransactionCheckJob(it) }
|
||||
.toMutableList()
|
||||
|
||||
Log.i(TAG, "Rechecking ${jobs.size} payments")
|
||||
if (jobs.isNotEmpty()) {
|
||||
jobs += PaymentLedgerUpdateJob.updateLedger()
|
||||
}
|
||||
ApplicationDependencies.getJobManager().addAll(jobs)
|
||||
}
|
||||
|
||||
override fun shouldRetry(e: Exception): Boolean = false
|
||||
|
||||
class Factory : Job.Factory<RecheckPaymentsMigrationJob> {
|
||||
override fun create(parameters: Parameters, serializedData: ByteArray?): RecheckPaymentsMigrationJob {
|
||||
return RecheckPaymentsMigrationJob(parameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user