mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Fix issue where a test user could have a tier but no subscriber.
This commit is contained in:
committed by
Cody Henthorne
parent
f8d7c27583
commit
ed9a945f05
@@ -55,6 +55,7 @@ import org.thoughtcrime.securesms.backup.v2.stream.EncryptedBackupWriter
|
||||
import org.thoughtcrime.securesms.backup.v2.stream.PlainTextBackupReader
|
||||
import org.thoughtcrime.securesms.backup.v2.stream.PlainTextBackupWriter
|
||||
import org.thoughtcrime.securesms.backup.v2.ui.subscription.MessageBackupsType
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaymentsRepository
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.RecurringInAppPaymentRepository
|
||||
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider
|
||||
import org.thoughtcrime.securesms.crypto.DatabaseSecretProvider
|
||||
@@ -350,12 +351,18 @@ object BackupRepository {
|
||||
fun turnOffAndDisableBackups(): Boolean {
|
||||
return try {
|
||||
Log.d(TAG, "Attempting to disable backups.")
|
||||
if (SignalStore.backup.backupTier == MessageBackupTier.PAID) {
|
||||
|
||||
val backupsSubscriber = InAppPaymentsRepository.getSubscriber(InAppPaymentSubscriberRecord.Type.BACKUP)
|
||||
if (SignalStore.backup.backupTier == MessageBackupTier.PAID && backupsSubscriber != null) {
|
||||
Log.d(TAG, "User is currently on a paid tier. Canceling.")
|
||||
RecurringInAppPaymentRepository.cancelActiveSubscriptionSync(InAppPaymentSubscriberRecord.Type.BACKUP)
|
||||
Log.d(TAG, "Successfully canceled paid tier.")
|
||||
}
|
||||
|
||||
if (backupsSubscriber == null) {
|
||||
Log.w(TAG, "No backup subscriber in the database. Proceeding with disabling backups anyway.")
|
||||
}
|
||||
|
||||
Log.d(TAG, "Disabling backups.")
|
||||
SignalStore.backup.disableBackups()
|
||||
SignalDatabase.attachments.clearAllArchiveData()
|
||||
|
||||
@@ -270,10 +270,15 @@ class RemoteBackupsSettingsViewModel : ViewModel() {
|
||||
return
|
||||
}
|
||||
hasActiveSignalSubscription && hasActiveGooglePlayBillingSubscription -> {
|
||||
Log.d(TAG, "Found erroneous mismatch. Clearing.")
|
||||
Log.d(TAG, "Found active signal subscription and active google play subscription. Clearing mismatch.")
|
||||
SignalStore.backup.subscriptionStateMismatchDetected = false
|
||||
}
|
||||
!hasActiveSignalSubscription && !hasActiveGooglePlayBillingSubscription -> {
|
||||
Log.d(TAG, "Found inactive signal subscription and inactive google play subscription. Clearing mismatch.")
|
||||
SignalStore.backup.subscriptionStateMismatchDetected = false
|
||||
}
|
||||
else -> {
|
||||
Log.w(TAG, "Hit unexpected subscription mismatch state: signal:false, google:true")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user