Add checks for user registration when attempting to access dontations or perform keep-alive.

This commit is contained in:
Alex Hart
2025-03-17 16:01:52 -03:00
parent a7fb84e7e6
commit 28d18a8012
2 changed files with 6 additions and 1 deletions

View File

@@ -41,7 +41,7 @@ class AppSettingsViewModel : ViewModel() {
disposables += RecurringInAppPaymentRepository.getActiveSubscription(InAppPaymentSubscriberRecord.Type.DONATION).subscribeBy(
onSuccess = { activeSubscription ->
store.update { state ->
state.copy(allowUserToGoToDonationManagementScreen = activeSubscription.isActive || InAppDonations.hasAtLeastOnePaymentMethodAvailable())
state.copy(allowUserToGoToDonationManagementScreen = SignalStore.account.isRegistered && (activeSubscription.isActive || InAppDonations.hasAtLeastOnePaymentMethodAvailable()))
}
},
onError = {}

View File

@@ -95,6 +95,11 @@ class InAppPaymentKeepAliveJob private constructor(
}
private fun doRun() {
if (!SignalStore.account.isRegistered) {
warn(type, "User is not registered. Skipping.")
return
}
val subscriber: InAppPaymentSubscriberRecord? = InAppPaymentsRepository.getSubscriber(type)
if (subscriber == null) {
info(type, "Subscriber not present. Skipping.")