mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Attempt to heal if we have everything we need but no entitlement.
This commit is contained in:
@@ -327,6 +327,12 @@ class InAppPaymentTable(context: Context, databaseHelper: SignalDatabase) : Data
|
||||
.run()
|
||||
}
|
||||
|
||||
fun hasPendingBackupRedemption(): Boolean {
|
||||
return readableDatabase.exists(TABLE_NAME)
|
||||
.where("$STATE = ? AND $TYPE = ?", State.serialize(State.PENDING), InAppPaymentType.serialize(InAppPaymentType.RECURRING_BACKUP))
|
||||
.run()
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves from the database the latest payment of the given type that is either in the PENDING or WAITING_FOR_AUTHORIZATION state.
|
||||
*/
|
||||
|
||||
@@ -152,7 +152,12 @@ class BackupSubscriptionCheckJob private constructor(parameters: Parameters) : C
|
||||
val hasTokenMismatch = purchaseToken?.let { hasLocalDevicePurchaseTokenMismatch(purchaseToken) } == true
|
||||
if (hasActiveSignalSubscription && hasTokenMismatch) {
|
||||
Log.i(TAG, "Encountered token mismatch with an active Signal subscription. Attempting to redeem against latest token.", true)
|
||||
enqueueRedemptionForNewToken(purchaseToken, product.price)
|
||||
rotateAndRedeem(purchaseToken, product.price)
|
||||
SignalStore.backup.subscriptionStateMismatchDetected = false
|
||||
return Result.success()
|
||||
} else if (purchaseToken != null && hasActiveSignalSubscription && !hasActivePaidBackupTier && !SignalDatabase.inAppPayments.hasPendingBackupRedemption()) {
|
||||
Log.i(TAG, "We have an active signal subscription and active purchase, but no entitlement and no pending redemption. Enqueuing a redemption now.")
|
||||
rotateAndRedeem(purchaseToken, product.price)
|
||||
SignalStore.backup.subscriptionStateMismatchDetected = false
|
||||
return Result.success()
|
||||
} else {
|
||||
@@ -203,7 +208,7 @@ class BackupSubscriptionCheckJob private constructor(parameters: Parameters) : C
|
||||
}
|
||||
}
|
||||
|
||||
private fun enqueueRedemptionForNewToken(localDevicePurchaseToken: String, localProductPrice: FiatMoney) {
|
||||
private fun rotateAndRedeem(localDevicePurchaseToken: String, localProductPrice: FiatMoney) {
|
||||
RecurringInAppPaymentRepository.ensureSubscriberIdSync(
|
||||
subscriberType = InAppPaymentSubscriberRecord.Type.BACKUP,
|
||||
isRotation = true,
|
||||
|
||||
Reference in New Issue
Block a user