mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Fix checks in backup subscription check job.
This commit is contained in:
@@ -259,6 +259,7 @@ class MessageBackupsFlowViewModel(
|
||||
val inAppPayment = SignalDatabase.inAppPayments.getById(inAppPaymentId)!!
|
||||
SignalDatabase.inAppPayments.update(
|
||||
inAppPayment.copy(
|
||||
state = InAppPaymentTable.State.PENDING,
|
||||
subscriberId = InAppPaymentsRepository.requireSubscriber(InAppPaymentSubscriberRecord.Type.BACKUP).subscriberId,
|
||||
data = inAppPayment.data.copy(
|
||||
redemption = inAppPayment.data.redemption!!.copy(
|
||||
|
||||
@@ -78,12 +78,6 @@ class BackupSubscriptionCheckJob private constructor(parameters: Parameters) : C
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
if (!SignalStore.backup.areBackupsEnabled) {
|
||||
Log.i(TAG, "Backups are not enabled on this device. Clearing mismatch value and exiting.")
|
||||
SignalStore.backup.subscriptionStateMismatchDetected = false
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
if (!AppDependencies.billingApi.isApiAvailable()) {
|
||||
Log.i(TAG, "Google Play Billing API is not available on this device. Clearing mismatch value and exiting.")
|
||||
SignalStore.backup.subscriptionStateMismatchDetected = false
|
||||
@@ -91,6 +85,8 @@ class BackupSubscriptionCheckJob private constructor(parameters: Parameters) : C
|
||||
}
|
||||
|
||||
val purchase: BillingPurchaseResult = AppDependencies.billingApi.queryPurchases()
|
||||
Log.i(TAG, "Retrieved purchase result from Billing api: $purchase")
|
||||
|
||||
val hasActivePurchase = purchase is BillingPurchaseResult.Success && purchase.isAcknowledged && purchase.isWithinTheLastMonth()
|
||||
val product: BillingProduct? = AppDependencies.billingApi.queryProduct()
|
||||
|
||||
|
||||
@@ -29,7 +29,20 @@ sealed interface BillingPurchaseResult {
|
||||
val oneMonthAgo = now - 31.days
|
||||
val purchaseTime = this.purchaseTime.milliseconds
|
||||
|
||||
return oneMonthAgo >= purchaseTime
|
||||
return oneMonthAgo < purchaseTime
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return """
|
||||
BillingPurchaseResult {
|
||||
purchaseState: $purchaseState
|
||||
purchaseToken: <redacted>
|
||||
purchaseTime: $purchaseTime
|
||||
isAcknowledged: $isAcknowledged
|
||||
isAutoRenewing: $isAutoRenewing
|
||||
isWithinTheLastMonth: ${isWithinTheLastMonth()}
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
data object UserCancelled : BillingPurchaseResult
|
||||
|
||||
Reference in New Issue
Block a user