mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Backup delete resub flow state fix.
This commit is contained in:
committed by
Cody Henthorne
parent
109d37c0d2
commit
ad652dbaf2
@@ -8,8 +8,6 @@ import io.reactivex.rxjava3.subjects.Subject
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.donations.PaymentSourceType
|
||||
import org.signal.donations.StripeApi
|
||||
import org.signal.libsignal.zkgroup.receipts.ReceiptCredentialPresentation
|
||||
import org.signal.libsignal.zkgroup.receipts.ReceiptCredentialRequestContext
|
||||
import org.thoughtcrime.securesms.backup.v2.MessageBackupTier
|
||||
import org.thoughtcrime.securesms.badges.Badges
|
||||
import org.thoughtcrime.securesms.badges.models.Badge
|
||||
@@ -70,42 +68,6 @@ class InAppPaymentValues internal constructor(store: KeyValueStore) : SignalStor
|
||||
private const val SUBSCRIPTION_CANCELATION_WATERMARK = "donation.subscription.cancelation.watermark"
|
||||
private const val SHOW_CANT_PROCESS_DIALOG = "show.cant.process.dialog"
|
||||
|
||||
/**
|
||||
* The current request context for subscription. This should be stored until either
|
||||
* it is successfully converted into a response, the end of period changes, or the user
|
||||
* manually cancels the subscription.
|
||||
*/
|
||||
private const val SUBSCRIPTION_CREDENTIAL_REQUEST = "subscription.credential.request"
|
||||
|
||||
/**
|
||||
* The current response presentation that can be submitted for a badge. This should be
|
||||
* stored until it is successfully redeemed, the end of period changes, or the user
|
||||
* manually cancels their subscription.
|
||||
*/
|
||||
private const val SUBSCRIPTION_CREDENTIAL_RECEIPT = "subscription.credential.receipt"
|
||||
|
||||
/**
|
||||
* Notes the "end of period" time for the latest subscription that we have started
|
||||
* to get a response presentation for. When this is equal to the latest "end of period"
|
||||
* it can be assumed that we have a request context that can be safely reused.
|
||||
*/
|
||||
private const val SUBSCRIPTION_EOP_STARTED_TO_CONVERT = "subscription.eop.convert"
|
||||
|
||||
/**
|
||||
* Notes the "end of period" time for the latest subscription that we have started
|
||||
* to redeem a response presentation for. When this is equal to the latest "end of
|
||||
* period" it can be assumed that we have a response presentation that we can submit
|
||||
* to get an active token for.
|
||||
*/
|
||||
private const val SUBSCRIPTION_EOP_STARTED_TO_REDEEM = "subscription.eop.redeem"
|
||||
|
||||
/**
|
||||
* Notes the "end of period" time for the latest subscription that we have successfully
|
||||
* and fully redeemed a token for. If this is equal to the latest "end of period" it is
|
||||
* assumed that there is no work to be done.
|
||||
*/
|
||||
private const val SUBSCRIPTION_EOP_REDEEMED = "subscription.eop.redeemed"
|
||||
|
||||
/**
|
||||
* Notes the type of payment the user utilized for the latest subscription. This is useful
|
||||
* in determining which error messaging they should see if something goes wrong.
|
||||
@@ -154,11 +116,6 @@ class InAppPaymentValues internal constructor(store: KeyValueStore) : SignalStor
|
||||
SUBSCRIPTION_CANCELATION_TIMESTAMP,
|
||||
SUBSCRIPTION_CANCELATION_WATERMARK,
|
||||
SHOW_CANT_PROCESS_DIALOG,
|
||||
SUBSCRIPTION_CREDENTIAL_REQUEST,
|
||||
SUBSCRIPTION_CREDENTIAL_RECEIPT,
|
||||
SUBSCRIPTION_EOP_STARTED_TO_CONVERT,
|
||||
SUBSCRIPTION_EOP_STARTED_TO_REDEEM,
|
||||
SUBSCRIPTION_EOP_REDEEMED,
|
||||
SUBSCRIPTION_PAYMENT_SOURCE_TYPE
|
||||
)
|
||||
|
||||
@@ -363,15 +320,6 @@ class InAppPaymentValues internal constructor(store: KeyValueStore) : SignalStor
|
||||
return getBoolean(SUBSCRIPTION_REDEMPTION_FAILED, false)
|
||||
}
|
||||
|
||||
fun markSubscriptionRedemptionFailed() {
|
||||
Log.w(TAG, "markSubscriptionRedemptionFailed()", Throwable(), true)
|
||||
putBoolean(SUBSCRIPTION_REDEMPTION_FAILED, true)
|
||||
}
|
||||
|
||||
fun clearSubscriptionRedemptionFailed() {
|
||||
putBoolean(SUBSCRIPTION_REDEMPTION_FAILED, false)
|
||||
}
|
||||
|
||||
@Deprecated("Cancellation status is now stored in InAppPaymentTable")
|
||||
fun setUnexpectedSubscriptionCancelationChargeFailure(chargeFailure: ActiveSubscription.ChargeFailure?) {
|
||||
if (chargeFailure == null) {
|
||||
@@ -439,9 +387,6 @@ class InAppPaymentValues internal constructor(store: KeyValueStore) : SignalStor
|
||||
unexpectedSubscriptionCancelationReason = null
|
||||
unexpectedSubscriptionCancelationTimestamp = 0L
|
||||
|
||||
clearSubscriptionRequestCredential()
|
||||
clearSubscriptionReceiptCredential()
|
||||
|
||||
val expiredBadge = getExpiredBadge()
|
||||
if (expiredBadge != null && expiredBadge.isSubscription()) {
|
||||
Log.d(TAG, "[updateLocalStateForManualCancellation] Clearing expired badge.")
|
||||
@@ -483,8 +428,6 @@ class InAppPaymentValues internal constructor(store: KeyValueStore) : SignalStor
|
||||
setUnexpectedSubscriptionCancelationChargeFailure(null)
|
||||
unexpectedSubscriptionCancelationReason = null
|
||||
unexpectedSubscriptionCancelationTimestamp = 0L
|
||||
refreshSubscriptionRequestCredential()
|
||||
clearSubscriptionReceiptCredential()
|
||||
|
||||
val expiredBadge = getExpiredBadge()
|
||||
if (expiredBadge != null && expiredBadge.isSubscription()) {
|
||||
@@ -504,38 +447,6 @@ class InAppPaymentValues internal constructor(store: KeyValueStore) : SignalStor
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshSubscriptionRequestCredential() {
|
||||
putBlob(SUBSCRIPTION_CREDENTIAL_REQUEST, InAppPaymentsRepository.generateRequestCredential().serialize())
|
||||
}
|
||||
|
||||
fun setSubscriptionRequestCredential(requestContext: ReceiptCredentialRequestContext) {
|
||||
putBlob(SUBSCRIPTION_CREDENTIAL_REQUEST, requestContext.serialize())
|
||||
}
|
||||
|
||||
fun getSubscriptionRequestCredential(): ReceiptCredentialRequestContext? {
|
||||
val bytes = getBlob(SUBSCRIPTION_CREDENTIAL_REQUEST, null) ?: return null
|
||||
|
||||
return ReceiptCredentialRequestContext(bytes)
|
||||
}
|
||||
|
||||
fun clearSubscriptionRequestCredential() {
|
||||
remove(SUBSCRIPTION_CREDENTIAL_REQUEST)
|
||||
}
|
||||
|
||||
fun setSubscriptionReceiptCredential(receiptCredentialPresentation: ReceiptCredentialPresentation) {
|
||||
putBlob(SUBSCRIPTION_CREDENTIAL_RECEIPT, receiptCredentialPresentation.serialize())
|
||||
}
|
||||
|
||||
fun getSubscriptionReceiptCredential(): ReceiptCredentialPresentation? {
|
||||
val bytes = getBlob(SUBSCRIPTION_CREDENTIAL_RECEIPT, null) ?: return null
|
||||
|
||||
return ReceiptCredentialPresentation(bytes)
|
||||
}
|
||||
|
||||
fun clearSubscriptionReceiptCredential() {
|
||||
remove(SUBSCRIPTION_CREDENTIAL_RECEIPT)
|
||||
}
|
||||
|
||||
@Deprecated("This information is now stored in InAppPaymentTable")
|
||||
fun setSubscriptionPaymentSourceType(paymentSourceType: PaymentSourceType) {
|
||||
putString(SUBSCRIPTION_PAYMENT_SOURCE_TYPE, paymentSourceType.code)
|
||||
@@ -546,10 +457,6 @@ class InAppPaymentValues internal constructor(store: KeyValueStore) : SignalStor
|
||||
return PaymentSourceType.fromCode(getString(SUBSCRIPTION_PAYMENT_SOURCE_TYPE, null))
|
||||
}
|
||||
|
||||
var subscriptionEndOfPeriodConversionStarted by longValue(SUBSCRIPTION_EOP_STARTED_TO_CONVERT, 0L)
|
||||
var subscriptionEndOfPeriodRedemptionStarted by longValue(SUBSCRIPTION_EOP_STARTED_TO_REDEEM, 0L)
|
||||
var subscriptionEndOfPeriodRedeemed by longValue(SUBSCRIPTION_EOP_REDEEMED, 0L)
|
||||
|
||||
fun appendToTerminalDonationQueue(terminalDonation: TerminalDonationQueue.TerminalDonation) {
|
||||
synchronized(this) {
|
||||
val pendingBytes = getBlob(DONATION_COMPLETE_QUEUE, null)
|
||||
|
||||
Reference in New Issue
Block a user