Don't fail backup redemption pipeline after 24hrs.

This commit is contained in:
Alex Hart
2025-09-09 11:46:59 -03:00
committed by GitHub
parent 3c7534f7fa
commit 40ba967192
7 changed files with 66 additions and 8 deletions

View File

@@ -38,6 +38,7 @@ import org.thoughtcrime.securesms.util.parcelers.MillisecondDurationParceler
import org.thoughtcrime.securesms.util.parcelers.NullableSubscriberIdParceler
import org.whispersystems.signalservice.api.subscriptions.SubscriberId
import kotlin.time.Duration
import kotlin.time.Duration.Companion.hours
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
@@ -184,6 +185,20 @@ class InAppPaymentTable(context: Context, databaseHelper: SignalDatabase) : Data
AppDependencies.databaseObserver.notifyInAppPaymentsObservers(inAppPayment)
}
fun getOldPendingPayments(type: InAppPaymentType): List<InAppPayment> {
val oneDayAgo = System.currentTimeMillis().milliseconds - 24.hours
return readableDatabase
.select()
.from(TABLE_NAME)
.where(
"$STATE = ? AND $TYPE = ? AND $UPDATED_AT <= ${oneDayAgo.inWholeSeconds}",
State.serialize(State.PENDING),
InAppPaymentType.serialize(type)
)
.run()
.readToList(mapper = InAppPayment::deserialize)
}
/**
* Returns true if the user has submitted a pre-pending recurring donation.
* In this state, the user would have had to cancel their subscription or be in the process of trying