Rename DonationValues to InAppPaymentValues.

This commit is contained in:
Alex Hart
2024-06-27 09:57:16 -03:00
committed by Cody Henthorne
parent b943df1ce4
commit 77d3116431
49 changed files with 204 additions and 204 deletions

View File

@@ -262,7 +262,7 @@ class BackupTest {
SignalDatabase.recipients.setProfileAvatar(self.id, "https://example.com/")
InAppPaymentsRepository.setSubscriber(InAppPaymentSubscriberRecord(SubscriberId.generate(), Currency.getInstance("USD"), InAppPaymentSubscriberRecord.Type.DONATION, false, InAppPaymentData.PaymentMethodType.UNKNOWN))
SignalStore.donations.setDisplayBadgesOnProfile(false)
SignalStore.inAppPayments.setDisplayBadgesOnProfile(false)
SignalStore.phoneNumberPrivacy.phoneNumberDiscoverabilityMode = PhoneNumberPrivacyValues.PhoneNumberDiscoverabilityMode.NOT_DISCOVERABLE
SignalStore.phoneNumberPrivacy.phoneNumberSharingMode = PhoneNumberPrivacyValues.PhoneNumberSharingMode.NOBODY

View File

@@ -36,10 +36,10 @@ class SubscriberIdMigrationJobTest {
@Test
fun givenUSDSubscriber_whenIRunSubscriberIdMigrationJob_thenIExpectASingleEntry() {
val subscriberId = SubscriberId.generate()
SignalStore.donations.setSubscriberCurrency(Currency.getInstance("USD"), InAppPaymentSubscriberRecord.Type.DONATION)
SignalStore.donations.setSubscriber("USD", subscriberId)
SignalStore.donations.setSubscriptionPaymentSourceType(PaymentSourceType.PayPal)
SignalStore.donations.shouldCancelSubscriptionBeforeNextSubscribeAttempt = true
SignalStore.inAppPayments.setSubscriberCurrency(Currency.getInstance("USD"), InAppPaymentSubscriberRecord.Type.DONATION)
SignalStore.inAppPayments.setSubscriber("USD", subscriberId)
SignalStore.inAppPayments.setSubscriptionPaymentSourceType(PaymentSourceType.PayPal)
SignalStore.inAppPayments.shouldCancelSubscriptionBeforeNextSubscribeAttempt = true
testSubject.run()

View File

@@ -782,7 +782,7 @@ object BackupRepository {
}
suspend fun getBackupsType(tier: MessageBackupTier): MessageBackupsType {
val backupCurrency = SignalStore.donations.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.BACKUP)
val backupCurrency = SignalStore.inAppPayments.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.BACKUP)
return when (tier) {
MessageBackupTier.FREE -> getFreeType(backupCurrency)
MessageBackupTier.PAID -> getPaidType(backupCurrency)

View File

@@ -38,7 +38,7 @@ object AccountDataProcessor {
val selfId = db.recipientTable.getByAci(signalStore.accountValues.aci!!).get()
val selfRecord = db.recipientTable.getRecordForSync(selfId)!!
val donationCurrency = signalStore.donationsValues.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION)
val donationCurrency = signalStore.inAppPaymentValues.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION)
val donationSubscriber = db.inAppPaymentSubscriberTable.getByCurrencyCode(donationCurrency.currencyCode, InAppPaymentSubscriberRecord.Type.DONATION)
emitter.emit(
@@ -64,14 +64,14 @@ object AccountDataProcessor {
hasViewedOnboardingStory = signalStore.storyValues.userHasViewedOnboardingStory,
hasSetMyStoriesPrivacy = signalStore.storyValues.userHasBeenNotifiedAboutStories,
keepMutedChatsArchived = signalStore.settingsValues.shouldKeepMutedChatsArchived(),
displayBadgesOnProfile = signalStore.donationsValues.getDisplayBadgesOnProfile(),
displayBadgesOnProfile = signalStore.inAppPaymentValues.getDisplayBadgesOnProfile(),
hasSeenGroupStoryEducationSheet = signalStore.storyValues.userHasSeenGroupStoryEducationSheet,
hasCompletedUsernameOnboarding = signalStore.uiHintValues.hasCompletedUsernameOnboarding()
),
donationSubscriberData = AccountData.SubscriberData(
subscriberId = donationSubscriber?.subscriberId?.bytes?.toByteString() ?: defaultAccountRecord.subscriberId,
currencyCode = donationSubscriber?.currency?.currencyCode ?: defaultAccountRecord.subscriberCurrencyCode,
manuallyCancelled = signalStore.donationsValues.isDonationSubscriptionManuallyCancelled()
manuallyCancelled = signalStore.inAppPaymentValues.isDonationSubscriptionManuallyCancelled()
)
)
)
@@ -96,7 +96,7 @@ object AccountDataProcessor {
SignalStore.settings.isPreferSystemContactPhotos = settings.preferContactAvatars
SignalStore.settings.universalExpireTimer = settings.universalExpireTimer
SignalStore.emoji.reactions = settings.preferredReactionEmoji
SignalStore.donations.setDisplayBadgesOnProfile(settings.displayBadgesOnProfile)
SignalStore.inAppPayments.setDisplayBadgesOnProfile(settings.displayBadgesOnProfile)
SignalStore.settings.setKeepMutedChatsArchived(settings.keepMutedChatsArchived)
SignalStore.story.userHasBeenNotifiedAboutStories = settings.hasSetMyStoriesPrivacy
SignalStore.story.userHasViewedOnboardingStory = settings.hasViewedOnboardingStory
@@ -121,7 +121,7 @@ object AccountDataProcessor {
}
if (accountData.donationSubscriberData.manuallyCancelled) {
SignalStore.donations.updateLocalStateForManualCancellation(InAppPaymentSubscriberRecord.Type.DONATION)
SignalStore.inAppPayments.updateLocalStateForManualCancellation(InAppPaymentSubscriberRecord.Type.DONATION)
}
}

View File

@@ -45,7 +45,7 @@ class BadgeRepository(context: Context) {
Log.d(TAG, "[setVisibilityForAllBadgesSync] Uploading profile...", true)
ProfileUtil.uploadProfileWithBadges(context, badges)
SignalStore.donations.setDisplayBadgesOnProfile(displayBadgesOnProfile)
SignalStore.inAppPayments.setDisplayBadgesOnProfile(displayBadgesOnProfile)
recipientTable.markNeedsSync(Recipient.self().id)
Log.d(TAG, "[setVisibilityForAllBadgesSync] Requesting data change sync...", true)

View File

@@ -43,7 +43,7 @@ object ExpiredGiftSheetConfiguration {
)
)
if (SignalStore.donations.isLikelyASustainer()) {
if (SignalStore.inAppPayments.isLikelyASustainer()) {
primaryButton(
text = DSLSettingsText.from(
stringId = android.R.string.ok

View File

@@ -33,7 +33,7 @@ class GiftFlowViewModel(
private val store = RxStore(
GiftFlowState(
currency = SignalStore.donations.getOneTimeCurrency()
currency = SignalStore.inAppPayments.getOneTimeCurrency()
)
)
private val disposables = CompositeDisposable()
@@ -66,7 +66,7 @@ class GiftFlowViewModel(
fun refresh() {
disposables.clear()
disposables += SignalStore.donations.observableOneTimeCurrency.subscribe { currency ->
disposables += SignalStore.inAppPayments.observableOneTimeCurrency.subscribe { currency ->
store.update {
it.copy(
currency = currency

View File

@@ -59,7 +59,7 @@ class ViewReceivedGiftViewModel(
.subscribe { badge ->
val otherBadges = Recipient.self().badges.filterNot { it.id == badge.id }
val hasOtherBadges = otherBadges.isNotEmpty()
val displayingBadges = SignalStore.donations.getDisplayBadgesOnProfile()
val displayingBadges = SignalStore.inAppPayments.getDisplayBadgesOnProfile()
val displayingOtherBadges = hasOtherBadges && displayingBadges
store.update {

View File

@@ -32,7 +32,7 @@ class ExpiredOneTimeBadgeBottomSheetDialogFragment : DSLSettingsBottomSheetFragm
private fun getConfiguration(): DSLConfiguration {
val args = ExpiredOneTimeBadgeBottomSheetDialogFragmentArgs.fromBundle(requireArguments())
val badge: Badge = args.badge
val isLikelyASustainer = SignalStore.donations.isLikelyASustainer()
val isLikelyASustainer = SignalStore.inAppPayments.isLikelyASustainer()
Log.d(TAG, "Displaying Expired Badge Fragment with bundle: ${requireArguments()}", true)

View File

@@ -96,7 +96,7 @@ class MonthlyDonationCanceledBottomSheetDialogFragment : ComposeBottomSheetDialo
dismissAllowingStateLoss()
},
onNotNowClicked = {
SignalStore.donations.showMonthlyDonationCanceledDialog = false
SignalStore.inAppPayments.showMonthlyDonationCanceledDialog = false
dismissAllowingStateLoss()
}
)

View File

@@ -58,8 +58,8 @@ class MonthlyDonationCanceledViewModel(
private fun initializeFromSignalStore() {
internalState.value = MonthlyDonationCanceledState(
loadState = MonthlyDonationCanceledState.LoadState.READY,
badge = SignalStore.donations.getExpiredBadge(),
errorMessage = getErrorMessage(SignalStore.donations.getUnexpectedSubscriptionCancelationChargeFailure())
badge = SignalStore.inAppPayments.getExpiredBadge(),
errorMessage = getErrorMessage(SignalStore.inAppPayments.getUnexpectedSubscriptionCancelationChargeFailure())
)
}

View File

@@ -38,7 +38,7 @@ class BadgesOverviewViewModel(
state.copy(
stage = if (state.stage == BadgesOverviewState.Stage.INIT) BadgesOverviewState.Stage.READY else state.stage,
allUnlockedBadges = recipient.badges,
displayBadgesOnProfile = SignalStore.donations.getDisplayBadgesOnProfile(),
displayBadgesOnProfile = SignalStore.inAppPayments.getDisplayBadgesOnProfile(),
featuredBadge = recipient.featuredBadge
)
}

View File

@@ -21,8 +21,8 @@ class AppSettingsViewModel : ViewModel() {
AppSettingsState(
Recipient.self(),
0,
SignalStore.donations.getExpiredGiftBadge() != null,
SignalStore.donations.isLikelyASustainer() || InAppDonations.hasAtLeastOnePaymentMethodAvailable(),
SignalStore.inAppPayments.getExpiredGiftBadge() != null,
SignalStore.inAppPayments.isLikelyASustainer() || InAppDonations.hasAtLeastOnePaymentMethodAvailable(),
TextSecurePreferences.isUnauthorizedReceived(AppDependencies.application) || !SignalStore.account.isRegistered,
SignalStore.misc.isClientDeprecated
)
@@ -62,6 +62,6 @@ class AppSettingsViewModel : ViewModel() {
}
fun refreshExpiredGiftBadge() {
store.update { it.copy(hasExpiredGiftBadge = SignalStore.donations.getExpiredGiftBadge() != null) }
store.update { it.copy(hasExpiredGiftBadge = SignalStore.inAppPayments.getExpiredGiftBadge() != null) }
}
}

View File

@@ -69,7 +69,7 @@ class InternalPendingOneTimeDonationConfigurationFragment : ComposeFragment() {
viewModel.state.value = viewModel.state.value.copy(error = viewModel.state.value.error!!.copy(code = it))
},
onSave = {
SignalStore.donations.setPendingOneTimeDonation(viewModel.state.value)
SignalStore.inAppPayments.setPendingOneTimeDonation(viewModel.state.value)
findNavController().popBackStack()
}
)

View File

@@ -557,9 +557,9 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
clickPref(
title = DSLSettingsText.from("Clear keep-alive timestamps"),
onClick = {
SignalStore.donations.subscriptionEndOfPeriodRedemptionStarted = 0L
SignalStore.donations.subscriptionEndOfPeriodConversionStarted = 0L
SignalStore.donations.setLastEndOfPeriod(0L)
SignalStore.inAppPayments.subscriptionEndOfPeriodRedemptionStarted = 0L
SignalStore.inAppPayments.subscriptionEndOfPeriodConversionStarted = 0L
SignalStore.inAppPayments.setLastEndOfPeriod(0L)
Toast.makeText(context, "Cleared", Toast.LENGTH_SHORT).show()
}
)
@@ -570,7 +570,7 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
clickPref(
title = DSLSettingsText.from("Clear pending one-time donation."),
onClick = {
SignalStore.donations.setPendingOneTimeDonation(null)
SignalStore.inAppPayments.setPendingOneTimeDonation(null)
}
)
} else {

View File

@@ -23,7 +23,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
store.update { it.copy(emojiVersion = version) }
}
val pendingOneTimeDonation: Observable<Boolean> = SignalStore.donations.observablePendingOneTimeDonation
val pendingOneTimeDonation: Observable<Boolean> = SignalStore.inAppPayments.observablePendingOneTimeDonation
.distinctUntilChanged()
.map { it.isPresent }
@@ -159,7 +159,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
canClearOnboardingState = SignalStore.story.hasDownloadedOnboardingStory && Stories.isFeatureEnabled(),
pnpInitialized = SignalStore.misc.hasPniInitializedDevices,
useConversationItemV2ForMedia = SignalStore.internal.useConversationItemV2Media(),
hasPendingOneTimeDonation = SignalStore.donations.getPendingOneTimeDonation() != null
hasPendingOneTimeDonation = SignalStore.inAppPayments.getPendingOneTimeDonation() != null
)
fun onClearOnboardingState() {

View File

@@ -38,7 +38,7 @@ class InternalTerminalDonationConfigurationFragment : ComposeFragment() {
override fun FragmentContent() {
InternalTerminalDonationConfigurationContent(
onAddClick = {
SignalStore.donations.appendToTerminalDonationQueue(it)
SignalStore.inAppPayments.appendToTerminalDonationQueue(it)
findNavController().popBackStack()
}
)

View File

@@ -117,11 +117,11 @@ class InternalDonorErrorConfigurationViewModel : ViewModel() {
fun clearErrorState(): Completable {
return Completable.fromAction {
synchronized(InAppPaymentSubscriberRecord.Type.DONATION) {
SignalStore.donations.setExpiredBadge(null)
SignalStore.donations.setExpiredGiftBadge(null)
SignalStore.donations.unexpectedSubscriptionCancelationReason = null
SignalStore.donations.unexpectedSubscriptionCancelationTimestamp = 0L
SignalStore.donations.setUnexpectedSubscriptionCancelationChargeFailure(null)
SignalStore.inAppPayments.setExpiredBadge(null)
SignalStore.inAppPayments.setExpiredGiftBadge(null)
SignalStore.inAppPayments.unexpectedSubscriptionCancelationReason = null
SignalStore.inAppPayments.unexpectedSubscriptionCancelationTimestamp = 0L
SignalStore.inAppPayments.setUnexpectedSubscriptionCancelationChargeFailure(null)
}
store.update {
@@ -135,24 +135,24 @@ class InternalDonorErrorConfigurationViewModel : ViewModel() {
}
private fun handleBoostExpiration(state: InternalDonorErrorConfigurationState) {
SignalStore.donations.setExpiredBadge(state.selectedBadge)
SignalStore.inAppPayments.setExpiredBadge(state.selectedBadge)
}
private fun handleGiftExpiration(state: InternalDonorErrorConfigurationState) {
SignalStore.donations.setExpiredGiftBadge(state.selectedBadge)
SignalStore.inAppPayments.setExpiredGiftBadge(state.selectedBadge)
}
private fun handleSubscriptionExpiration(state: InternalDonorErrorConfigurationState) {
SignalStore.donations.updateLocalStateForLocalSubscribe(InAppPaymentSubscriberRecord.Type.DONATION)
SignalStore.donations.setExpiredBadge(state.selectedBadge)
SignalStore.inAppPayments.updateLocalStateForLocalSubscribe(InAppPaymentSubscriberRecord.Type.DONATION)
SignalStore.inAppPayments.setExpiredBadge(state.selectedBadge)
handleSubscriptionPaymentFailure(state)
}
private fun handleSubscriptionPaymentFailure(state: InternalDonorErrorConfigurationState) {
SignalStore.donations.unexpectedSubscriptionCancelationReason = state.selectedUnexpectedSubscriptionCancellation?.status
SignalStore.donations.unexpectedSubscriptionCancelationTimestamp = System.currentTimeMillis()
SignalStore.donations.showMonthlyDonationCanceledDialog = true
SignalStore.donations.setUnexpectedSubscriptionCancelationChargeFailure(
SignalStore.inAppPayments.unexpectedSubscriptionCancelationReason = state.selectedUnexpectedSubscriptionCancellation?.status
SignalStore.inAppPayments.unexpectedSubscriptionCancelationTimestamp = System.currentTimeMillis()
SignalStore.inAppPayments.showMonthlyDonationCanceledDialog = true
SignalStore.inAppPayments.setUnexpectedSubscriptionCancelationChargeFailure(
state.selectedStripeDeclineCode?.let {
ActiveSubscription.ChargeFailure(
it.code,

View File

@@ -62,7 +62,7 @@ object InAppDonations {
* Whether the user is using a device that supports GooglePay, based off Wallet API and phone number.
*/
fun isGooglePayAvailable(): Boolean {
return SignalStore.donations.isGooglePayReady && !LocaleRemoteConfig.isGooglePayDisabled()
return SignalStore.inAppPayments.isGooglePayReady && !LocaleRemoteConfig.isGooglePayDisabled()
}
/**

View File

@@ -313,7 +313,7 @@ object InAppPaymentsRepository {
return if (paymentMethodType != InAppPaymentData.PaymentMethodType.UNKNOWN) {
paymentMethodType
} else if (subscriberType == InAppPaymentSubscriberRecord.Type.DONATION) {
SignalStore.donations.getSubscriptionPaymentSourceType().toPaymentMethodType()
SignalStore.inAppPayments.getSubscriptionPaymentSourceType().toPaymentMethodType()
} else {
return InAppPaymentData.PaymentMethodType.UNKNOWN
}
@@ -325,9 +325,9 @@ object InAppPaymentsRepository {
@JvmStatic
fun isUserManuallyCancelled(subscriberType: InAppPaymentSubscriberRecord.Type): Boolean {
return if (subscriberType == InAppPaymentSubscriberRecord.Type.DONATION) {
SignalStore.donations.isDonationSubscriptionManuallyCancelled()
SignalStore.inAppPayments.isDonationSubscriptionManuallyCancelled()
} else {
SignalStore.donations.isBackupSubscriptionManuallyCancelled()
SignalStore.inAppPayments.isBackupSubscriptionManuallyCancelled()
}
}
@@ -341,7 +341,7 @@ object InAppPaymentsRepository {
@JvmStatic
fun getFallbackLastEndOfPeriod(subscriberType: InAppPaymentSubscriberRecord.Type): Duration {
return if (subscriberType == InAppPaymentSubscriberRecord.Type.DONATION) {
SignalStore.donations.getLastEndOfPeriod().seconds
SignalStore.inAppPayments.getLastEndOfPeriod().seconds
} else {
0.seconds
}
@@ -361,7 +361,7 @@ object InAppPaymentsRepository {
@WorkerThread
fun setShouldCancelSubscriptionBeforeNextSubscribeAttempt(subscriberType: InAppPaymentSubscriberRecord.Type, subscriberId: SubscriberId?, shouldCancel: Boolean) {
if (subscriberType == InAppPaymentSubscriberRecord.Type.DONATION) {
SignalStore.donations.shouldCancelSubscriptionBeforeNextSubscribeAttempt = shouldCancel
SignalStore.inAppPayments.shouldCancelSubscriptionBeforeNextSubscribeAttempt = shouldCancel
}
if (subscriberId == null) {
@@ -384,7 +384,7 @@ object InAppPaymentsRepository {
val latestSubscriber = getSubscriber(subscriberType)
return latestSubscriber?.requiresCancel ?: if (subscriberType == InAppPaymentSubscriberRecord.Type.DONATION) {
SignalStore.donations.shouldCancelSubscriptionBeforeNextSubscribeAttempt
SignalStore.inAppPayments.shouldCancelSubscriptionBeforeNextSubscribeAttempt
} else {
false
}
@@ -401,7 +401,7 @@ object InAppPaymentsRepository {
val subscriber = SignalDatabase.inAppPaymentSubscribers.getByCurrencyCode(currency.currencyCode, type)
return if (subscriber == null && type == InAppPaymentSubscriberRecord.Type.DONATION) {
SignalStore.donations.getSubscriber(currency)
SignalStore.inAppPayments.getSubscriber(currency)
} else {
subscriber
}
@@ -413,7 +413,7 @@ object InAppPaymentsRepository {
@JvmStatic
@WorkerThread
fun getSubscriber(type: InAppPaymentSubscriberRecord.Type): InAppPaymentSubscriberRecord? {
val currency = SignalStore.donations.getSubscriptionCurrency(type)
val currency = SignalStore.inAppPayments.getSubscriptionCurrency(type)
Log.d(TAG, "Attempting to retrieve subscriber of type $type for ${currency.currencyCode}")
return getSubscriber(currency, type)

View File

@@ -52,7 +52,7 @@ object RecurringInAppPaymentRepository {
.subscribeOn(Schedulers.io())
.flatMap(ServiceResponse<ActiveSubscription>::flattenResult)
.doOnSuccess { activeSubscription ->
if (activeSubscription.isActive && activeSubscription.activeSubscription.endOfCurrentPeriod > SignalStore.donations.getLastEndOfPeriod()) {
if (activeSubscription.isActive && activeSubscription.activeSubscription.endOfCurrentPeriod > SignalStore.inAppPayments.getLastEndOfPeriod()) {
InAppPaymentKeepAliveJob.enqueueAndTrackTime(System.currentTimeMillis().milliseconds)
}
}
@@ -121,7 +121,7 @@ object RecurringInAppPaymentRepository {
InAppPaymentsRepository.setSubscriber(
InAppPaymentSubscriberRecord(
subscriberId = subscriberId,
currency = SignalStore.donations.getSubscriptionCurrency(subscriberType),
currency = SignalStore.inAppPayments.getSubscriptionCurrency(subscriberType),
type = subscriberType,
requiresCancel = false,
paymentMethodType = InAppPaymentData.PaymentMethodType.UNKNOWN
@@ -141,7 +141,7 @@ object RecurringInAppPaymentRepository {
serviceResponse.resultOrThrow
Log.d(TAG, "Cancelled active subscription.", true)
SignalStore.donations.updateLocalStateForManualCancellation(subscriberType)
SignalStore.inAppPayments.updateLocalStateForManualCancellation(subscriberType)
MultiDeviceSubscriptionSyncRequestJob.enqueue()
InAppPaymentsRepository.scheduleSyncForAccountRecordChange()
}
@@ -157,7 +157,7 @@ object RecurringInAppPaymentRepository {
return Single.fromCallable { InAppPaymentsRepository.getShouldCancelSubscriptionBeforeNextSubscribeAttempt(subscriberType) }.flatMapCompletable {
if (it) {
cancelActiveSubscription(subscriberType).doOnComplete {
SignalStore.donations.updateLocalStateForManualCancellation(subscriberType)
SignalStore.inAppPayments.updateLocalStateForManualCancellation(subscriberType)
MultiDeviceSubscriptionSyncRequestJob.enqueue()
}
} else {
@@ -212,14 +212,14 @@ object RecurringInAppPaymentRepository {
.flatMapCompletable {
if (it.status == 200 || it.status == 204) {
Log.d(TAG, "Successfully set user subscription to level $subscriptionLevel with response code ${it.status}", true)
SignalStore.donations.updateLocalStateForLocalSubscribe(subscriberType)
SignalStore.inAppPayments.updateLocalStateForLocalSubscribe(subscriberType)
syncAccountRecord().subscribe()
LevelUpdate.updateProcessingState(false)
Completable.complete()
} else {
if (it.applicationError.isPresent) {
Log.w(TAG, "Failed to set user subscription to level $subscriptionLevel with response code ${it.status}", it.applicationError.get(), true)
SignalStore.donations.clearLevelOperations()
SignalStore.inAppPayments.clearLevelOperations()
} else {
Log.w(TAG, "Failed to set user subscription to level $subscriptionLevel", it.executionError.orElse(null), true)
}
@@ -256,14 +256,14 @@ object RecurringInAppPaymentRepository {
fun getOrCreateLevelUpdateOperation(tag: String, subscriptionLevel: String): LevelUpdateOperation {
Log.d(tag, "Retrieving level update operation for $subscriptionLevel")
val levelUpdateOperation = SignalStore.donations.getLevelOperation(subscriptionLevel)
val levelUpdateOperation = SignalStore.inAppPayments.getLevelOperation(subscriptionLevel)
return if (levelUpdateOperation == null) {
val newOperation = LevelUpdateOperation(
idempotencyKey = IdempotencyKey.generate(),
level = subscriptionLevel
)
SignalStore.donations.setLevelOperation(newOperation)
SignalStore.inAppPayments.setLevelOperation(newOperation)
LevelUpdate.updateProcessingState(true)
Log.d(tag, "Created a new operation for $subscriptionLevel")
newOperation
@@ -281,7 +281,7 @@ object RecurringInAppPaymentRepository {
private fun updateLocalSubscriptionStateAndScheduleDataSync(subscriberType: InAppPaymentSubscriberRecord.Type): Completable {
return Completable.fromAction {
Log.d(TAG, "Marking subscription cancelled...", true)
SignalStore.donations.updateLocalStateForManualCancellation(subscriberType)
SignalStore.inAppPayments.updateLocalStateForManualCancellation(subscriberType)
MultiDeviceSubscriptionSyncRequestJob.enqueue()
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
StorageSyncHelper.scheduleSyncForDataChange()

View File

@@ -42,7 +42,7 @@ class TerminalDonationDelegate(
private val badgeRepository = TerminalDonationRepository()
override fun onResume(owner: LifecycleOwner) {
val donations = SignalStore.donations.consumeTerminalDonations()
val donations = SignalStore.inAppPayments.consumeTerminalDonations()
for (donation in donations) {
if (donation.isLongRunningPaymentMethod && (donation.error == null || donation.error.type != DonationErrorValue.Type.REDEMPTION)) {
TerminalDonationBottomSheet.show(fragmentManager, donation)
@@ -57,7 +57,7 @@ class TerminalDonationDelegate(
}
}
val verifiedMonthlyDonation: Stripe3DSData? = SignalStore.donations.consumeVerifiedSubscription3DSData()
val verifiedMonthlyDonation: Stripe3DSData? = SignalStore.inAppPayments.consumeVerifiedSubscription3DSData()
if (verifiedMonthlyDonation != null) {
DonationPendingBottomSheet().apply {
arguments = DonationPendingBottomSheetArgs.Builder(verifiedMonthlyDonation.inAppPayment).build().toBundle()
@@ -80,7 +80,7 @@ class TerminalDonationDelegate(
DonationPendingBottomSheet().apply {
arguments = DonationPendingBottomSheetArgs.Builder(payment).build().toBundle()
}.show(fragmentManager, null)
} else if (payment.data.error != null && payment.data.cancellation != null && payment.data.cancellation.reason != InAppPaymentData.Cancellation.Reason.MANUAL && SignalStore.donations.showMonthlyDonationCanceledDialog) {
} else if (payment.data.error != null && payment.data.cancellation != null && payment.data.cancellation.reason != InAppPaymentData.Cancellation.Reason.MANUAL && SignalStore.inAppPayments.showMonthlyDonationCanceledDialog) {
MonthlyDonationCanceledBottomSheetDialogFragment.show(fragmentManager)
}
}

View File

@@ -46,7 +46,7 @@ class TerminalDonationViewModel(
disposables += repository.getBadge(donationCompleted)
.map { badge ->
val hasOtherBadges = Recipient.self().badges.filterNot { it.id == badge.id }.isNotEmpty()
val isDisplayingBadges = SignalStore.donations.getDisplayBadgesOnProfile()
val isDisplayingBadges = SignalStore.inAppPayments.getDisplayBadgesOnProfile()
val toggleType = when {
hasOtherBadges && isDisplayingBadges -> ToggleType.MAKE_FEATURED_BADGE

View File

@@ -24,9 +24,9 @@ class SetCurrencyViewModel(
private val store = Store(
SetCurrencyState(
selectedCurrencyCode = if (inAppPaymentType.recurring) {
SignalStore.donations.getSubscriptionCurrency(inAppPaymentType.requireSubscriberType()).currencyCode
SignalStore.inAppPayments.getSubscriptionCurrency(inAppPaymentType.requireSubscriberType()).currencyCode
} else {
SignalStore.donations.getOneTimeCurrency().currencyCode
SignalStore.inAppPayments.getOneTimeCurrency().currencyCode
},
currencies = supportedCurrencyCodes
.map(Currency::getInstance)
@@ -40,7 +40,7 @@ class SetCurrencyViewModel(
store.update { it.copy(selectedCurrencyCode = selectedCurrencyCode) }
if (!inAppPaymentType.recurring) {
SignalStore.donations.setOneTimeCurrency(Currency.getInstance(selectedCurrencyCode))
SignalStore.inAppPayments.setOneTimeCurrency(Currency.getInstance(selectedCurrencyCode))
} else {
val currency = Currency.getInstance(selectedCurrencyCode)
val subscriber = InAppPaymentsRepository.getSubscriber(currency, inAppPaymentType.requireSubscriberType())

View File

@@ -91,7 +91,7 @@ data class DonateToSignalState(
data class OneTimeDonationState(
val badge: Badge? = null,
val selectedCurrency: Currency = SignalStore.donations.getOneTimeCurrency(),
val selectedCurrency: Currency = SignalStore.inAppPayments.getOneTimeCurrency(),
val boosts: List<Boost> = emptyList(),
val selectedBoost: Boost? = null,
val customAmount: FiatMoney = FiatMoney(BigDecimal.ZERO, selectedCurrency),
@@ -114,7 +114,7 @@ data class DonateToSignalState(
}
data class MonthlyDonationState(
val selectedCurrency: Currency = SignalStore.donations.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION),
val selectedCurrency: Currency = SignalStore.inAppPayments.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION),
val subscriptions: List<Subscription> = emptyList(),
private val _activeSubscription: ActiveSubscription? = null,
val selectedSubscription: Subscription? = null,

View File

@@ -248,7 +248,7 @@ class DonateToSignalViewModel(
}
}.distinctUntilChanged()
val oneTimeDonationFromStore: Observable<Optional<PendingOneTimeDonation>> = SignalStore.donations.observablePendingOneTimeDonation
val oneTimeDonationFromStore: Observable<Optional<PendingOneTimeDonation>> = SignalStore.inAppPayments.observablePendingOneTimeDonation
.map { pending -> pending.filter { !it.isExpired } }
.distinctUntilChanged()
@@ -283,13 +283,13 @@ class DonateToSignalViewModel(
)
val boosts: Observable<Map<Currency, List<Boost>>> = oneTimeInAppPaymentRepository.getBoosts().toObservable()
val oneTimeCurrency: Observable<Currency> = SignalStore.donations.observableOneTimeCurrency
val oneTimeCurrency: Observable<Currency> = SignalStore.inAppPayments.observableOneTimeCurrency
oneTimeDonationDisposables += Observable.combineLatest(boosts, oneTimeCurrency) { boostMap, currency ->
val boostList = if (currency in boostMap) {
boostMap[currency]!!
} else {
SignalStore.donations.setOneTimeCurrency(PlatformCurrencyUtil.USD)
SignalStore.inAppPayments.setOneTimeCurrency(PlatformCurrencyUtil.USD)
listOf()
}
@@ -387,7 +387,7 @@ class DonateToSignalViewModel(
onSuccess = { subscriptions ->
if (subscriptions.isNotEmpty()) {
val priceCurrencies = subscriptions[0].prices.map { it.currency }
val selectedCurrency = SignalStore.donations.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION)
val selectedCurrency = SignalStore.inAppPayments.getSubscriptionCurrency(InAppPaymentSubscriberRecord.Type.DONATION)
if (selectedCurrency !in priceCurrencies) {
Log.w(TAG, "Unsupported currency selection. Defaulting to USD. $selectedCurrency isn't supported.")
@@ -403,7 +403,7 @@ class DonateToSignalViewModel(
}
private fun monitorSubscriptionCurrency() {
monthlyDonationDisposables += SignalStore.donations.observableRecurringDonationCurrency.subscribe {
monthlyDonationDisposables += SignalStore.inAppPayments.observableRecurringDonationCurrency.subscribe {
store.update { state ->
state.copy(monthlyDonationState = state.monthlyDonationState.copy(selectedCurrency = it))
}

View File

@@ -42,7 +42,7 @@ class GatewaySelectorViewModel(
val gatewayConfiguration = gatewaySelectorRepository.getAvailableGatewayConfiguration(currencyCode = args.inAppPayment.data.amount!!.currencyCode)
disposables += Single.zip(isGooglePayAvailable, gatewayConfiguration, ::Pair).subscribeBy { (googlePayAvailable, gatewayConfiguration) ->
SignalStore.donations.isGooglePayReady = googlePayAvailable
SignalStore.inAppPayments.isGooglePayReady = googlePayAvailable
store.update {
it.copy(
loading = false,

View File

@@ -106,7 +106,7 @@ class PayPalPaymentInProgressViewModel(
disposables += RecurringInAppPaymentRepository.cancelActiveSubscription(subscriberType).subscribeBy(
onComplete = {
Log.d(TAG, "Cancellation succeeded", true)
SignalStore.donations.updateLocalStateForManualCancellation(subscriberType)
SignalStore.inAppPayments.updateLocalStateForManualCancellation(subscriberType)
MultiDeviceSubscriptionSyncRequestJob.enqueue()
RecurringInAppPaymentRepository.syncAccountRecord().subscribe()
store.update { DonationProcessorStage.COMPLETE }

View File

@@ -82,7 +82,7 @@ object DonationRedemptionJobWatcher {
val jobSpec: JobSpec? = externalLaunchJobSpec ?: redemptionJobSpec ?: receiptJobSpec
return if (redemptionType == RedemptionType.SUBSCRIPTION && jobSpec == null && SignalStore.donations.getSubscriptionRedemptionFailed()) {
return if (redemptionType == RedemptionType.SUBSCRIPTION && jobSpec == null && SignalStore.inAppPayments.getSubscriptionRedemptionFailed()) {
DonationRedemptionJobStatus.FailedSubscription
} else {
jobSpec?.toDonationRedemptionStatus(redemptionType) ?: DonationRedemptionJobStatus.None

View File

@@ -83,9 +83,9 @@ class ManageDonationsFragment :
BadgePreview.register(adapter)
NetworkFailure.register(adapter)
val expiredGiftBadge = SignalStore.donations.getExpiredGiftBadge()
val expiredGiftBadge = SignalStore.inAppPayments.getExpiredGiftBadge()
if (expiredGiftBadge != null) {
SignalStore.donations.setExpiredGiftBadge(null)
SignalStore.inAppPayments.setExpiredGiftBadge(null)
ExpiredGiftSheet.show(childFragmentManager, expiredGiftBadge)
}
@@ -227,7 +227,7 @@ class ManageDonationsFragment :
}
private fun DSLConfiguration.presentNetworkFailureSettings(state: ManageDonationsState, hasReceipts: Boolean) {
if (SignalStore.donations.isLikelyASustainer()) {
if (SignalStore.inAppPayments.isLikelyASustainer()) {
presentSubscriptionSettingsWithNetworkError(state)
} else {
presentNotADonorSettings(hasReceipts)
@@ -409,7 +409,7 @@ class ManageDonationsFragment :
startActivity(AppSettingsActivity.help(requireContext(), HelpFragment.DONATION_INDEX))
}
.setOnDismissListener {
SignalStore.donations.setPendingOneTimeDonation(null)
SignalStore.inAppPayments.setPendingOneTimeDonation(null)
}
.show()
}
@@ -429,7 +429,7 @@ class ManageDonationsFragment :
}
.setPositiveButton(android.R.string.ok, null)
.setOnDismissListener {
SignalStore.donations.setPendingOneTimeDonation(null)
SignalStore.inAppPayments.setPendingOneTimeDonation(null)
}
.show()
}

View File

@@ -94,7 +94,7 @@ class ManageDonationsViewModel : ViewModel() {
}
disposables += Observable.combineLatest(
SignalStore.donations.observablePendingOneTimeDonation,
SignalStore.inAppPayments.observablePendingOneTimeDonation,
InAppPaymentsRepository.observeInAppPaymentRedemption(InAppPaymentType.ONE_TIME_DONATION)
) { pendingFromStore, pendingFromJob ->
if (pendingFromStore.isPresent) {

View File

@@ -89,7 +89,7 @@ class ThanksForYourSupportBottomSheetDialogFragment : FixedRoundedCornerBottomSh
val otherBadges = Recipient.self().badges.filterNot { it.id == args.badge.id }
val hasOtherBadges = otherBadges.isNotEmpty()
val displayingBadges = SignalStore.donations.getDisplayBadgesOnProfile()
val displayingBadges = SignalStore.inAppPayments.getDisplayBadgesOnProfile()
if (hasOtherBadges && displayingBadges) {
switch.isChecked = false

View File

@@ -492,37 +492,37 @@ public class ConversationListFragment extends MainFragment implements ActionMode
RecaptchaProofBottomSheetFragment.show(getChildFragmentManager());
}
Badge expiredBadge = SignalStore.donations().getExpiredBadge();
String subscriptionCancellationReason = SignalStore.donations().getUnexpectedSubscriptionCancelationReason();
Badge expiredBadge = SignalStore.inAppPayments().getExpiredBadge();
String subscriptionCancellationReason = SignalStore.inAppPayments().getUnexpectedSubscriptionCancelationReason();
UnexpectedSubscriptionCancellation unexpectedSubscriptionCancellation = UnexpectedSubscriptionCancellation.fromStatus(subscriptionCancellationReason);
long subscriptionFailureTimestamp = SignalStore.donations().getUnexpectedSubscriptionCancelationTimestamp();
long subscriptionFailureWatermark = SignalStore.donations().getUnexpectedSubscriptionCancelationWatermark();
long subscriptionFailureTimestamp = SignalStore.inAppPayments().getUnexpectedSubscriptionCancelationTimestamp();
long subscriptionFailureWatermark = SignalStore.inAppPayments().getUnexpectedSubscriptionCancelationWatermark();
boolean isWatermarkPriorToTimestamp = subscriptionFailureWatermark < subscriptionFailureTimestamp;
if (unexpectedSubscriptionCancellation != null &&
!SignalStore.donations().isDonationSubscriptionManuallyCancelled() &&
SignalStore.donations().showCantProcessDialog() &&
!SignalStore.inAppPayments().isDonationSubscriptionManuallyCancelled() &&
SignalStore.inAppPayments().showCantProcessDialog() &&
isWatermarkPriorToTimestamp)
{
Log.w(TAG, "Displaying bottom sheet for unexpected cancellation: " + unexpectedSubscriptionCancellation, true);
MonthlyDonationCanceledBottomSheetDialogFragment.show(getChildFragmentManager());
SignalStore.donations().setUnexpectedSubscriptionCancelationWatermark(subscriptionFailureTimestamp);
} else if (unexpectedSubscriptionCancellation != null && SignalStore.donations().isDonationSubscriptionManuallyCancelled()) {
SignalStore.inAppPayments().setUnexpectedSubscriptionCancelationWatermark(subscriptionFailureTimestamp);
} else if (unexpectedSubscriptionCancellation != null && SignalStore.inAppPayments().isDonationSubscriptionManuallyCancelled()) {
Log.w(TAG, "Unexpected cancellation detected but not displaying dialog because user manually cancelled their subscription: " + unexpectedSubscriptionCancellation, true);
SignalStore.donations().setUnexpectedSubscriptionCancelationWatermark(subscriptionFailureTimestamp);
} else if (unexpectedSubscriptionCancellation != null && !SignalStore.donations().showCantProcessDialog()) {
SignalStore.inAppPayments().setUnexpectedSubscriptionCancelationWatermark(subscriptionFailureTimestamp);
} else if (unexpectedSubscriptionCancellation != null && !SignalStore.inAppPayments().showCantProcessDialog()) {
Log.w(TAG, "Unexpected cancellation detected but not displaying dialog because user has silenced it.", true);
SignalStore.donations().setUnexpectedSubscriptionCancelationWatermark(subscriptionFailureTimestamp);
SignalStore.inAppPayments().setUnexpectedSubscriptionCancelationWatermark(subscriptionFailureTimestamp);
}
if (expiredBadge != null && expiredBadge.isBoost()) {
SignalStore.donations().setExpiredBadge(null);
SignalStore.inAppPayments().setExpiredBadge(null);
Log.w(TAG, "Displaying bottom sheet for an expired badge", true);
ExpiredOneTimeBadgeBottomSheetDialogFragment.show(
expiredBadge,
unexpectedSubscriptionCancellation,
SignalStore.donations().getUnexpectedSubscriptionCancelationChargeFailure(),
SignalStore.inAppPayments().getUnexpectedSubscriptionCancelationChargeFailure(),
getParentFragmentManager()
);
}

View File

@@ -87,7 +87,7 @@ class InAppPaymentSubscriberTable(
.values(InAppPaymentSubscriberSerializer.serialize(inAppPaymentSubscriberRecord))
.run(conflictStrategy = SQLiteDatabase.CONFLICT_REPLACE)
SignalStore.donations.setSubscriberCurrency(
SignalStore.inAppPayments.setSubscriberCurrency(
inAppPaymentSubscriberRecord.currency,
inAppPaymentSubscriberRecord.type
)
@@ -152,7 +152,7 @@ class InAppPaymentSubscriberTable(
val currencyCode = input.requireNonNullString(CURRENCY_CODE).takeIf { it.isNotEmpty() }
return InAppPaymentSubscriberRecord(
subscriberId = SubscriberId.deserialize(input.requireNonNullString(SUBSCRIBER_ID)),
currency = currencyCode?.let { Currency.getInstance(it) } ?: SignalStore.donations.getSubscriptionCurrency(type),
currency = currencyCode?.let { Currency.getInstance(it) } ?: SignalStore.inAppPayments.getSubscriptionCurrency(type),
type = type,
requiresCancel = input.requireBoolean(REQUIRES_CANCEL) || currencyCode.isNullOrBlank(),
paymentMethodType = InAppPaymentData.PaymentMethodType.fromValue(input.requireInt(PAYMENT_METHOD_TYPE)) ?: InAppPaymentData.PaymentMethodType.UNKNOWN

View File

@@ -186,7 +186,7 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
@Override
public void onFailure() {
if (terminalDonation.error != null) {
SignalStore.donations().appendToTerminalDonationQueue(terminalDonation);
SignalStore.inAppPayments().appendToTerminalDonationQueue(terminalDonation);
} else {
Log.w(TAG, "Job is in terminal state without an error on TerminalDonation.");
}
@@ -242,7 +242,7 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
.serialize());
if (donationErrorSource == DonationErrorSource.GIFT) {
SignalStore.donations().setPendingOneTimeDonation(null);
SignalStore.inAppPayments().setPendingOneTimeDonation(null);
}
} else {
Log.w(TAG, "Encountered a retryable exception: " + response.getStatus(), response.getExecutionError().orElse(null), true);
@@ -261,7 +261,7 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
.code(Integer.toString(statusCode))
.build();
SignalStore.donations().setPendingOneTimeDonationError(
SignalStore.inAppPayments().setPendingOneTimeDonationError(
donationErrorValue
);
@@ -301,7 +301,7 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
.code(code)
.build();
SignalStore.donations().setPendingOneTimeDonationError(
SignalStore.inAppPayments().setPendingOneTimeDonationError(
donationErrorValue
);

View File

@@ -136,14 +136,14 @@ public class DonationReceiptRedemptionJob extends BaseJob {
if (isForSubscription()) {
Log.d(TAG, "Marking subscription failure", true);
SignalStore.donations().markSubscriptionRedemptionFailed();
SignalStore.inAppPayments().markSubscriptionRedemptionFailed();
MultiDeviceSubscriptionSyncRequestJob.enqueue();
} else if (giftMessageId != NO_ID) {
SignalDatabase.messages().markGiftRedemptionFailed(giftMessageId);
}
if (terminalDonation != null) {
SignalStore.donations().appendToTerminalDonationQueue(terminalDonation);
SignalStore.inAppPayments().appendToTerminalDonationQueue(terminalDonation);
}
}
@@ -194,7 +194,7 @@ public class DonationReceiptRedemptionJob extends BaseJob {
Log.d(TAG, "Attempting to redeem token... isForSubscription: " + isForSubscription(), true);
ServiceResponse<EmptyResponse> response = AppDependencies.getDonationsService()
.redeemDonationReceipt(presentation,
SignalStore.donations().getDisplayBadgesOnProfile(),
SignalStore.inAppPayments().getDisplayBadgesOnProfile(),
makePrimary);
if (response.getApplicationError().isPresent()) {
@@ -211,7 +211,7 @@ public class DonationReceiptRedemptionJob extends BaseJob {
.code(Integer.toString(response.getStatus()))
.build();
SignalStore.donations().setPendingOneTimeDonationError(
SignalStore.inAppPayments().setPendingOneTimeDonationError(
donationErrorValue
);
@@ -232,12 +232,12 @@ public class DonationReceiptRedemptionJob extends BaseJob {
if (isForSubscription()) {
Log.d(TAG, "Clearing subscription failure", true);
SignalStore.donations().clearSubscriptionRedemptionFailed();
SignalStore.inAppPayments().clearSubscriptionRedemptionFailed();
Log.i(TAG, "Recording end of period from active subscription", true);
SignalStore.donations()
.setSubscriptionEndOfPeriodRedeemed(SignalStore.donations()
SignalStore.inAppPayments()
.setSubscriptionEndOfPeriodRedeemed(SignalStore.inAppPayments()
.getSubscriptionEndOfPeriodRedemptionStarted());
SignalStore.donations().clearSubscriptionReceiptCredential();
SignalStore.inAppPayments().clearSubscriptionReceiptCredential();
} else if (giftMessageId != NO_ID) {
Log.d(TAG, "Marking gift redemption completed for " + giftMessageId);
SignalDatabase.messages().markGiftRedemptionCompleted(giftMessageId);
@@ -249,7 +249,7 @@ public class DonationReceiptRedemptionJob extends BaseJob {
}
if (isForOneTimeDonation()) {
SignalStore.donations().setPendingOneTimeDonation(null);
SignalStore.inAppPayments().setPendingOneTimeDonation(null);
}
}
@@ -257,7 +257,7 @@ public class DonationReceiptRedemptionJob extends BaseJob {
final ReceiptCredentialPresentation receiptCredentialPresentation;
if (isForSubscription()) {
receiptCredentialPresentation = SignalStore.donations().getSubscriptionReceiptCredential();
receiptCredentialPresentation = SignalStore.inAppPayments().getSubscriptionReceiptCredential();
} else {
receiptCredentialPresentation = null;
}
@@ -325,7 +325,7 @@ public class DonationReceiptRedemptionJob extends BaseJob {
return;
}
SignalStore.donations().appendToTerminalDonationQueue(terminalDonation);
SignalStore.inAppPayments().appendToTerminalDonationQueue(terminalDonation);
}
@Override

View File

@@ -70,7 +70,7 @@ class ExternalLaunchDonationJob private constructor(
if (donationError != null) {
when (stripe3DSData.inAppPayment.type) {
InAppPaymentType.ONE_TIME_DONATION -> {
SignalStore.donations.setPendingOneTimeDonation(
SignalStore.inAppPayments.setPendingOneTimeDonation(
DonationSerializationHelper.createPendingOneTimeDonationProto(
Badges.fromDatabaseBadge(stripe3DSData.inAppPayment.data.badge!!),
stripe3DSData.paymentSourceType,
@@ -82,7 +82,7 @@ class ExternalLaunchDonationJob private constructor(
}
InAppPaymentType.RECURRING_DONATION -> {
SignalStore.donations.appendToTerminalDonationQueue(
SignalStore.inAppPayments.appendToTerminalDonationQueue(
TerminalDonationQueue.TerminalDonation(
level = stripe3DSData.inAppPayment.data.level,
isLongRunningPaymentMethod = stripe3DSData.isLongRunning,
@@ -123,7 +123,7 @@ class ExternalLaunchDonationJob private constructor(
SignalDatabase.donationReceipts.addReceipt(donationReceiptRecord)
Log.i(TAG, "Creating and inserting one-time pending donation.", true)
SignalStore.donations.setPendingOneTimeDonation(
SignalStore.inAppPayments.setPendingOneTimeDonation(
DonationSerializationHelper.createPendingOneTimeDonationProto(
Badges.fromDatabaseBadge(stripe3DSData.inAppPayment.data.badge!!),
stripe3DSData.paymentSourceType,
@@ -154,7 +154,7 @@ class ExternalLaunchDonationJob private constructor(
Log.i(TAG, "Set default payment method via Signal service!", true)
Log.i(TAG, "Storing the subscription payment source type locally.", true)
SignalStore.donations.setSubscriptionPaymentSourceType(stripe3DSData.paymentSourceType)
SignalStore.inAppPayments.setSubscriptionPaymentSourceType(stripe3DSData.paymentSourceType)
val subscriptionLevel = stripe3DSData.inAppPayment.data.level.toString()
@@ -171,13 +171,13 @@ class ExternalLaunchDonationJob private constructor(
)
getResultOrThrow(updateSubscriptionLevelResponse, doOnApplicationError = {
SignalStore.donations.clearLevelOperations()
SignalStore.inAppPayments.clearLevelOperations()
})
if (updateSubscriptionLevelResponse.status in listOf(200, 204)) {
Log.d(TAG, "Successfully set user subscription to level $subscriptionLevel with response code ${updateSubscriptionLevelResponse.status}", true)
SignalStore.donations.updateLocalStateForLocalSubscribe(subscriber.type)
SignalStore.donations.setVerifiedSubscription3DSData(stripe3DSData)
SignalStore.inAppPayments.updateLocalStateForLocalSubscribe(subscriber.type)
SignalStore.inAppPayments.setVerifiedSubscription3DSData(stripe3DSData)
SignalDatabase.recipients.markNeedsSync(Recipient.self().id)
StorageSyncHelper.scheduleSyncForDataChange()
} else {
@@ -223,7 +223,7 @@ class ExternalLaunchDonationJob private constructor(
Log.w(TAG, "An application error was present. ${serviceResponse.status}", serviceResponse.applicationError.get(), true)
doOnApplicationError()
SignalStore.donations.appendToTerminalDonationQueue(
SignalStore.inAppPayments.appendToTerminalDonationQueue(
TerminalDonationQueue.TerminalDonation(
level = stripe3DSData.inAppPayment.data.level,
isLongRunningPaymentMethod = stripe3DSData.isLongRunning,

View File

@@ -104,7 +104,7 @@ class InAppPaymentAuthCheckJob private constructor(parameters: Parameters) : Bas
}
private fun migrateLegacyData() {
val pending3DSData = SignalStore.donations.consumePending3DSData()
val pending3DSData = SignalStore.inAppPayments.consumePending3DSData()
if (pending3DSData != null) {
Log.i(TAG, "Found legacy data. Performing migration.", true)
@@ -249,7 +249,7 @@ class InAppPaymentAuthCheckJob private constructor(parameters: Parameters) : Bas
val updateLevelResult = checkResult(updateLevelResponse)
if (updateLevelResult is CheckResult.Failure) {
SignalStore.donations.clearLevelOperations()
SignalStore.inAppPayments.clearLevelOperations()
return CheckResult.Failure(updateLevelResult.errorData)
}

View File

@@ -65,7 +65,7 @@ class InAppPaymentKeepAliveJob private constructor(
@JvmStatic
fun enqueueAndTrackTimeIfNecessary() {
// TODO -- This should only be enqueued if we are completely drained of old subscription jobs. (No pending, no runnning)
val lastKeepAliveTime = SignalStore.donations.getLastKeepAliveLaunchTime().milliseconds
val lastKeepAliveTime = SignalStore.inAppPayments.getLastKeepAliveLaunchTime().milliseconds
val now = System.currentTimeMillis().milliseconds
if (lastKeepAliveTime > now) {
@@ -83,7 +83,7 @@ class InAppPaymentKeepAliveJob private constructor(
fun enqueueAndTrackTime(now: Duration) {
AppDependencies.jobManager.add(create(InAppPaymentSubscriberRecord.Type.DONATION))
AppDependencies.jobManager.add(create(InAppPaymentSubscriberRecord.Type.BACKUP))
SignalStore.donations.setLastKeepAliveLaunchTime(now.inWholeMilliseconds)
SignalStore.inAppPayments.setLastKeepAliveLaunchTime(now.inWholeMilliseconds)
}
}
@@ -239,7 +239,7 @@ class InAppPaymentKeepAliveJob private constructor(
info(type, "End of period has changed. Requesting receipt refresh. (old: $oldEndOfPeriod, new: $endOfCurrentPeriod)")
if (type == InAppPaymentSubscriberRecord.Type.DONATION) {
SignalStore.donations.setLastEndOfPeriod(endOfCurrentPeriod.inWholeSeconds)
SignalStore.inAppPayments.setLastEndOfPeriod(endOfCurrentPeriod.inWholeSeconds)
}
val inAppPaymentId = SignalDatabase.inAppPayments.insert(

View File

@@ -142,7 +142,7 @@ class InAppPaymentRecurringContextJob private constructor(
if (inAppPayment.type.requireSubscriberType() == InAppPaymentSubscriberRecord.Type.DONATION) {
info("Recording last end of period.")
SignalStore.donations.setLastEndOfPeriod(subscription.endOfCurrentPeriod)
SignalStore.inAppPayments.setLastEndOfPeriod(subscription.endOfCurrentPeriod)
}
SignalDatabase.inAppPayments.update(

View File

@@ -162,7 +162,7 @@ class InAppPaymentRedemptionJob private constructor(
.donationsService
.redeemDonationReceipt(
receiptCredentialPresentation,
SignalStore.donations.getDisplayBadgesOnProfile(),
SignalStore.inAppPayments.getDisplayBadgesOnProfile(),
jobData.makePrimary
)
@@ -221,7 +221,7 @@ class InAppPaymentRedemptionJob private constructor(
.donationsService
.redeemDonationReceipt(
receiptCredentialPresentation,
SignalStore.donations.getDisplayBadgesOnProfile(),
SignalStore.inAppPayments.getDisplayBadgesOnProfile(),
jobData.makePrimary
)
}

View File

@@ -379,7 +379,7 @@ public class RefreshOwnProfileJob extends BaseJob {
.get();
Log.d(TAG, "Marking subscription badge as expired, should notify next time the conversation list is open.", true);
SignalStore.donations().setExpiredBadge(mostRecentExpiration);
SignalStore.inAppPayments().setExpiredBadge(mostRecentExpiration);
if (!InAppPaymentsRepository.isUserManuallyCancelled(InAppPaymentSubscriberRecord.Type.DONATION)) {
Log.d(TAG, "Detected an unexpected subscription expiry.", true);
@@ -421,16 +421,16 @@ public class RefreshOwnProfileJob extends BaseJob {
.get();
Log.d(TAG, "Marking boost badge as expired, should notify next time the conversation list is open.", true);
SignalStore.donations().setExpiredBadge(mostRecentExpiration);
SignalStore.inAppPayments().setExpiredBadge(mostRecentExpiration);
} else {
Badge badge = SignalStore.donations().getExpiredBadge();
Badge badge = SignalStore.inAppPayments().getExpiredBadge();
if (badge != null && badge.isSubscription() && remoteHasSubscriptionBadges) {
Log.d(TAG, "Remote has subscription badges. Clearing local expired subscription badge.", true);
SignalStore.donations().setExpiredBadge(null);
SignalStore.inAppPayments().setExpiredBadge(null);
} else if (badge != null && badge.isBoost() && remoteHasBoostBadges) {
Log.d(TAG, "Remote has boost badges. Clearing local expired boost badge.", true);
SignalStore.donations().setExpiredBadge(null);
SignalStore.inAppPayments().setExpiredBadge(null);
}
}
@@ -444,10 +444,10 @@ public class RefreshOwnProfileJob extends BaseJob {
.get();
Log.d(TAG, "Marking gift badge as expired, should notify next time the manage donations screen is open.", true);
SignalStore.donations().setExpiredGiftBadge(mostRecentExpiration);
SignalStore.inAppPayments().setExpiredGiftBadge(mostRecentExpiration);
} else if (remoteHasGiftBadges) {
Log.d(TAG, "We have remote gift badges. Clearing local expired gift badge.", true);
SignalStore.donations().setExpiredGiftBadge(null);
SignalStore.inAppPayments().setExpiredGiftBadge(null);
}
boolean userHasVisibleBadges = badges.stream().anyMatch(SignalServiceProfile.Badge::isVisible);
@@ -456,7 +456,7 @@ public class RefreshOwnProfileJob extends BaseJob {
List<Badge> appBadges = badges.stream().map(Badges::fromServiceBadge).collect(Collectors.toList());
if (userHasVisibleBadges && userHasInvisibleBadges) {
boolean displayBadgesOnProfile = SignalStore.donations().getDisplayBadgesOnProfile();
boolean displayBadgesOnProfile = SignalStore.inAppPayments().getDisplayBadgesOnProfile();
Log.d(TAG, "Detected mixed visibility of badges. Telling the server to mark them all " +
(displayBadgesOnProfile ? "" : "not") +
" visible.", true);

View File

@@ -93,17 +93,17 @@ public class SubscriptionKeepAliveJob extends BaseJob {
}
final long endOfCurrentPeriod = activeSubscription.getActiveSubscription().getEndOfCurrentPeriod();
if (endOfCurrentPeriod > SignalStore.donations().getLastEndOfPeriod()) {
if (endOfCurrentPeriod > SignalStore.inAppPayments().getLastEndOfPeriod()) {
Log.i(TAG,
String.format(Locale.US,
"Last end of period change. Requesting receipt refresh. (old: %d to new: %d)",
SignalStore.donations().getLastEndOfPeriod(),
SignalStore.inAppPayments().getLastEndOfPeriod(),
activeSubscription.getActiveSubscription().getEndOfCurrentPeriod()),
true);
SignalStore.donations().setLastEndOfPeriod(endOfCurrentPeriod);
SignalStore.donations().clearSubscriptionRequestCredential();
SignalStore.donations().clearSubscriptionReceiptCredential();
SignalStore.inAppPayments().setLastEndOfPeriod(endOfCurrentPeriod);
SignalStore.inAppPayments().clearSubscriptionRequestCredential();
SignalStore.inAppPayments().clearSubscriptionReceiptCredential();
MultiDeviceSubscriptionSyncRequestJob.enqueue();
}
@@ -114,22 +114,22 @@ public class SubscriptionKeepAliveJob extends BaseJob {
ByteString.EMPTY
);
if (endOfCurrentPeriod > SignalStore.donations().getSubscriptionEndOfPeriodConversionStarted()) {
if (endOfCurrentPeriod > SignalStore.inAppPayments().getSubscriptionEndOfPeriodConversionStarted()) {
Log.i(TAG, "Subscription end of period is after the conversion end of period. Storing it, generating a credential, and enqueuing the continuation job chain.", true);
SignalStore.donations().setSubscriptionEndOfPeriodConversionStarted(endOfCurrentPeriod);
SignalStore.donations().refreshSubscriptionRequestCredential();
SignalStore.inAppPayments().setSubscriptionEndOfPeriodConversionStarted(endOfCurrentPeriod);
SignalStore.inAppPayments().refreshSubscriptionRequestCredential();
SubscriptionReceiptRequestResponseJob.createSubscriptionContinuationJobChain(true, -1L, terminalDonation).enqueue();
} else if (endOfCurrentPeriod > SignalStore.donations().getSubscriptionEndOfPeriodRedemptionStarted()) {
if (SignalStore.donations().getSubscriptionRequestCredential() == null) {
} else if (endOfCurrentPeriod > SignalStore.inAppPayments().getSubscriptionEndOfPeriodRedemptionStarted()) {
if (SignalStore.inAppPayments().getSubscriptionRequestCredential() == null) {
Log.i(TAG, "We have not started a redemption, but do not have a request credential. Possible that the subscription changed.", true);
return;
}
Log.i(TAG, "We have a request credential and have not yet turned it into a redeemable token.", true);
SubscriptionReceiptRequestResponseJob.createSubscriptionContinuationJobChain(true, -1L, terminalDonation).enqueue();
} else if (endOfCurrentPeriod > SignalStore.donations().getSubscriptionEndOfPeriodRedeemed()) {
if (SignalStore.donations().getSubscriptionReceiptCredential() == null) {
} else if (endOfCurrentPeriod > SignalStore.inAppPayments().getSubscriptionEndOfPeriodRedeemed()) {
if (SignalStore.inAppPayments().getSubscriptionReceiptCredential() == null) {
Log.i(TAG, "We have successfully started redemption but have no stored token. Possible that the subscription changed.", true);
return;
}

View File

@@ -132,7 +132,7 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
@Override
public void onFailure() {
if (terminalDonation.error != null) {
SignalStore.donations().appendToTerminalDonationQueue(terminalDonation);
SignalStore.inAppPayments().appendToTerminalDonationQueue(terminalDonation);
} else {
Log.w(TAG, "Job is in terminal state without an error on TerminalDonation.");
}
@@ -155,7 +155,7 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
}
private void doRun() throws Exception {
ReceiptCredentialRequestContext requestContext = SignalStore.donations().getSubscriptionRequestCredential();
ReceiptCredentialRequestContext requestContext = SignalStore.inAppPayments().getSubscriptionRequestCredential();
ActiveSubscription activeSubscription = getLatestSubscriptionInformation();
ActiveSubscription.Subscription subscription = activeSubscription.getActiveSubscription();
@@ -203,16 +203,16 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
throw new RetryableException();
} else {
Log.i(TAG, "Subscription is valid, proceeding with request for ReceiptCredentialResponse", true);
long storedEndOfPeriod = SignalStore.donations().getLastEndOfPeriod();
long storedEndOfPeriod = SignalStore.inAppPayments().getLastEndOfPeriod();
if (storedEndOfPeriod < subscription.getEndOfCurrentPeriod()) {
Log.i(TAG, "Storing lastEndOfPeriod and syncing with linked devices", true);
SignalStore.donations().setLastEndOfPeriod(subscription.getEndOfCurrentPeriod());
SignalStore.inAppPayments().setLastEndOfPeriod(subscription.getEndOfCurrentPeriod());
MultiDeviceSubscriptionSyncRequestJob.enqueue();
}
if (SignalStore.donations().getSubscriptionEndOfPeriodConversionStarted() == 0L) {
if (SignalStore.inAppPayments().getSubscriptionEndOfPeriodConversionStarted() == 0L) {
Log.i(TAG, "Marking the start of initial conversion.", true);
SignalStore.donations().setSubscriptionEndOfPeriodConversionStarted(subscription.getEndOfCurrentPeriod());
SignalStore.inAppPayments().setSubscriptionEndOfPeriodConversionStarted(subscription.getEndOfCurrentPeriod());
}
}
@@ -235,9 +235,9 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
Log.d(TAG, "Validated credential. Recording receipt and handing off to redemption job.", true);
SignalDatabase.donationReceipts().addReceipt(DonationReceiptRecord.createForSubscription(subscription));
SignalStore.donations().clearSubscriptionRequestCredential();
SignalStore.donations().setSubscriptionReceiptCredential(receiptCredentialPresentation);
SignalStore.donations().setSubscriptionEndOfPeriodRedemptionStarted(subscription.getEndOfCurrentPeriod());
SignalStore.inAppPayments().clearSubscriptionRequestCredential();
SignalStore.inAppPayments().setSubscriptionReceiptCredential(receiptCredentialPresentation);
SignalStore.inAppPayments().setSubscriptionEndOfPeriodRedemptionStarted(subscription.getEndOfCurrentPeriod());
setOutputData(new JsonJobData.Builder()
.putBlobAsString(DonationReceiptRedemptionJob.INPUT_TERMINAL_DONATION, terminalDonation.encode())
@@ -290,7 +290,7 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
switch (response.getStatus()) {
case 204:
Log.w(TAG, "Payment is still processing. Trying again.", response.getApplicationError().get(), true);
SignalStore.donations().clearSubscriptionRedemptionFailed();
SignalStore.inAppPayments().clearSubscriptionRedemptionFailed();
throw new RetryableException();
case 400:
Log.w(TAG, "Receipt credential request failed to validate.", response.getApplicationError().get(), true);
@@ -359,13 +359,13 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
if (isForKeepAlive) {
Log.d(TAG, "Subscription canceled during keep-alive. Setting UnexpectedSubscriptionCancelation state...", true);
SignalStore.donations().setUnexpectedSubscriptionCancelationChargeFailure(chargeFailure);
SignalStore.donations().setUnexpectedSubscriptionCancelationReason(subscription.getStatus());
SignalStore.donations().setUnexpectedSubscriptionCancelationTimestamp(subscription.getEndOfCurrentPeriod());
SignalStore.donations().setShowMonthlyDonationCanceledDialog(true);
SignalStore.inAppPayments().setUnexpectedSubscriptionCancelationChargeFailure(chargeFailure);
SignalStore.inAppPayments().setUnexpectedSubscriptionCancelationReason(subscription.getStatus());
SignalStore.inAppPayments().setUnexpectedSubscriptionCancelationTimestamp(subscription.getEndOfCurrentPeriod());
SignalStore.inAppPayments().setShowMonthlyDonationCanceledDialog(true);
AppDependencies.getDonationsService().getDonationsConfiguration(Locale.getDefault()).getResult().ifPresent(config -> {
SignalStore.donations().setExpiredBadge(DonationsConfigurationExtensionsKt.getBadge(config, subscription.getLevel()));
SignalStore.inAppPayments().setExpiredBadge(DonationsConfigurationExtensionsKt.getBadge(config, subscription.getLevel()));
});
MultiDeviceSubscriptionSyncRequestJob.enqueue();
@@ -375,7 +375,7 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
StripeDeclineCode declineCode = StripeDeclineCode.Companion.getFromCode(chargeFailure.getOutcomeNetworkReason());
StripeFailureCode failureCode = StripeFailureCode.Companion.getFromCode(chargeFailure.getCode());
DonationError.PaymentSetupError paymentSetupError;
PaymentSourceType paymentSourceType = SignalStore.donations().getSubscriptionPaymentSourceType();
PaymentSourceType paymentSourceType = SignalStore.inAppPayments().getSubscriptionPaymentSourceType();
boolean isStripeSource = paymentSourceType instanceof PaymentSourceType.Stripe;
if (declineCode.isKnown() && isStripeSource) {
@@ -421,7 +421,7 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
PayPalDeclineCode declineCode = new PayPalDeclineCode(code);
DonationError.PaymentSetupError paymentSetupError;
PaymentSourceType paymentSourceType = SignalStore.donations().getSubscriptionPaymentSourceType();
PaymentSourceType paymentSourceType = SignalStore.inAppPayments().getSubscriptionPaymentSourceType();
boolean isPayPalSource = paymentSourceType instanceof PaymentSourceType.PayPal;
if (declineCode.getKnownCode() != null && isPayPalSource) {
@@ -518,10 +518,10 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
byte[] rawTerminalDonation = data.getStringAsBlob(DATA_TERMINAL_DONATION);
ReceiptCredentialRequestContext requestContext;
if (requestContextBytes != null && SignalStore.donations().getSubscriptionRequestCredential() == null) {
if (requestContextBytes != null && SignalStore.inAppPayments().getSubscriptionRequestCredential() == null) {
try {
requestContext = new ReceiptCredentialRequestContext(requestContextBytes);
SignalStore.donations().setSubscriptionRequestCredential(requestContext);
SignalStore.inAppPayments().setSubscriptionRequestCredential(requestContext);
} catch (InvalidInputException e) {
Log.e(TAG, "Failed to generate request context from bytes", e);
throw new AssertionError(e);

View File

@@ -34,13 +34,13 @@ import java.util.Optional
import java.util.concurrent.TimeUnit
/**
* Key-Value store for donation related values. Note that most of this file will be deprecated after the release of
* Key-Value store for in app payment related values. Note that most of this file will be deprecated after the release of
* InAppPayments (90day rollout window + 30day max job lifespan window)
*/
class DonationsValues internal constructor(store: KeyValueStore) : SignalStoreValues(store) {
class InAppPaymentValues internal constructor(store: KeyValueStore) : SignalStoreValues(store) {
companion object {
private val TAG = Log.tag(DonationsValues::class.java)
private val TAG = Log.tag(InAppPaymentValues::class.java)
private const val KEY_DONATION_SUBSCRIPTION_CURRENCY_CODE = "donation.currency.code"
private const val KEY_BACKUPS_SUBSCRIPTION_CURRENCY_CODE = "donation.backups.currency.code"

View File

@@ -28,7 +28,7 @@ class SignalStore(private val store: KeyValueStore) {
val onboardingValues = OnboardingValues(store)
val wallpaperValues = WallpaperValues(store)
val paymentsValues = PaymentsValues(store)
val donationsValues = DonationsValues(store)
val inAppPaymentValues = InAppPaymentValues(store)
val proxyValues = ProxyValues(store)
val rateLimitValues = RateLimitValues(store)
val chatColorsValues = ChatColorsValues(store)
@@ -68,7 +68,7 @@ class SignalStore(private val store: KeyValueStore) {
onboarding.onFirstEverAppLaunch()
wallpaper.onFirstEverAppLaunch()
payments.onFirstEverAppLaunch()
donations.onFirstEverAppLaunch()
inAppPayments.onFirstEverAppLaunch()
proxy.onFirstEverAppLaunch()
rateLimit.onFirstEverAppLaunch()
chatColors.onFirstEverAppLaunch()
@@ -98,7 +98,7 @@ class SignalStore(private val store: KeyValueStore) {
onboarding.keysToIncludeInBackup +
wallpaper.keysToIncludeInBackup +
payments.keysToIncludeInBackup +
donations.keysToIncludeInBackup +
inAppPayments.keysToIncludeInBackup +
proxy.keysToIncludeInBackup +
rateLimit.keysToIncludeInBackup +
chatColors.keysToIncludeInBackup +
@@ -209,9 +209,9 @@ class SignalStore(private val store: KeyValueStore) {
get() = instance.paymentsValues
@JvmStatic
@get:JvmName("donations")
val donations: DonationsValues
get() = instance.donationsValues
@get:JvmName("inAppPayments")
val inAppPayments: InAppPaymentValues
get() = instance.inAppPaymentValues
@JvmStatic
@get:JvmName("proxy")

View File

@@ -34,32 +34,32 @@ final class LogSectionBadges implements LogSection {
if (latestRecurringDonation != null) {
return new StringBuilder().append("Badge Count : ").append(Recipient.self().getBadges().size()).append("\n")
.append("ExpiredBadge : ").append(SignalStore.donations().getExpiredBadge() != null).append("\n")
.append("LastKeepAliveLaunchTime : ").append(SignalStore.donations().getLastKeepAliveLaunchTime()).append("\n")
.append("LastEndOfPeriod : ").append(SignalStore.donations().getLastEndOfPeriod()).append("\n")
.append("ExpiredBadge : ").append(SignalStore.inAppPayments().getExpiredBadge() != null).append("\n")
.append("LastKeepAliveLaunchTime : ").append(SignalStore.inAppPayments().getLastKeepAliveLaunchTime()).append("\n")
.append("LastEndOfPeriod : ").append(SignalStore.inAppPayments().getLastEndOfPeriod()).append("\n")
.append("InAppPayment.State : ").append(latestRecurringDonation.getState()).append("\n")
.append("InAppPayment.EndOfPeriod : ").append(latestRecurringDonation.getEndOfPeriodSeconds()).append("\n")
.append("InAppPaymentData.RedemptionState: ").append(getRedemptionStage(latestRecurringDonation.getData())).append("\n")
.append("InAppPaymentData.Error : ").append(getError(latestRecurringDonation.getData())).append("\n")
.append("InAppPaymentData.Cancellation : ").append(getCancellation(latestRecurringDonation.getData())).append("\n")
.append("DisplayBadgesOnProfile : ").append(SignalStore.donations().getDisplayBadgesOnProfile()).append("\n")
.append("DisplayBadgesOnProfile : ").append(SignalStore.inAppPayments().getDisplayBadgesOnProfile()).append("\n")
.append("ShouldCancelBeforeNextAttempt : ").append(InAppPaymentsRepository.getShouldCancelSubscriptionBeforeNextSubscribeAttempt(InAppPaymentSubscriberRecord.Type.DONATION)).append("\n")
.append("IsUserManuallyCancelledDonation : ").append(SignalStore.donations().isDonationSubscriptionManuallyCancelled()).append("\n");
.append("IsUserManuallyCancelledDonation : ").append(SignalStore.inAppPayments().isDonationSubscriptionManuallyCancelled()).append("\n");
} else {
return new StringBuilder().append("Badge Count : ").append(Recipient.self().getBadges().size()).append("\n")
.append("ExpiredBadge : ").append(SignalStore.donations().getExpiredBadge() != null).append("\n")
.append("LastKeepAliveLaunchTime : ").append(SignalStore.donations().getLastKeepAliveLaunchTime()).append("\n")
.append("LastEndOfPeriod : ").append(SignalStore.donations().getLastEndOfPeriod()).append("\n")
.append("SubscriptionEndOfPeriodConversionStarted: ").append(SignalStore.donations().getSubscriptionEndOfPeriodConversionStarted()).append("\n")
.append("SubscriptionEndOfPeriodRedemptionStarted: ").append(SignalStore.donations().getSubscriptionEndOfPeriodRedemptionStarted()).append("\n")
.append("SubscriptionEndOfPeriodRedeemed : ").append(SignalStore.donations().getSubscriptionEndOfPeriodRedeemed()).append("\n")
.append("IsUserManuallyCancelledDonation : ").append(SignalStore.donations().isDonationSubscriptionManuallyCancelled()).append("\n")
.append("DisplayBadgesOnProfile : ").append(SignalStore.donations().getDisplayBadgesOnProfile()).append("\n")
.append("SubscriptionRedemptionFailed : ").append(SignalStore.donations().getSubscriptionRedemptionFailed()).append("\n")
.append("ShouldCancelBeforeNextAttempt : ").append(SignalStore.donations().getShouldCancelSubscriptionBeforeNextSubscribeAttempt()).append("\n")
.append("Has unconverted request context : ").append(SignalStore.donations().getSubscriptionRequestCredential() != null).append("\n")
.append("Has unredeemed receipt presentation : ").append(SignalStore.donations().getSubscriptionReceiptCredential() != null).append("\n");
.append("ExpiredBadge : ").append(SignalStore.inAppPayments().getExpiredBadge() != null).append("\n")
.append("LastKeepAliveLaunchTime : ").append(SignalStore.inAppPayments().getLastKeepAliveLaunchTime()).append("\n")
.append("LastEndOfPeriod : ").append(SignalStore.inAppPayments().getLastEndOfPeriod()).append("\n")
.append("SubscriptionEndOfPeriodConversionStarted: ").append(SignalStore.inAppPayments().getSubscriptionEndOfPeriodConversionStarted()).append("\n")
.append("SubscriptionEndOfPeriodRedemptionStarted: ").append(SignalStore.inAppPayments().getSubscriptionEndOfPeriodRedemptionStarted()).append("\n")
.append("SubscriptionEndOfPeriodRedeemed : ").append(SignalStore.inAppPayments().getSubscriptionEndOfPeriodRedeemed()).append("\n")
.append("IsUserManuallyCancelledDonation : ").append(SignalStore.inAppPayments().isDonationSubscriptionManuallyCancelled()).append("\n")
.append("DisplayBadgesOnProfile : ").append(SignalStore.inAppPayments().getDisplayBadgesOnProfile()).append("\n")
.append("SubscriptionRedemptionFailed : ").append(SignalStore.inAppPayments().getSubscriptionRedemptionFailed()).append("\n")
.append("ShouldCancelBeforeNextAttempt : ").append(SignalStore.inAppPayments().getShouldCancelSubscriptionBeforeNextSubscribeAttempt()).append("\n")
.append("Has unconverted request context : ").append(SignalStore.inAppPayments().getSubscriptionRequestCredential() != null).append("\n")
.append("Has unredeemed receipt presentation : ").append(SignalStore.inAppPayments().getSubscriptionReceiptCredential() != null).append("\n");
}
}

View File

@@ -31,7 +31,7 @@ internal class SubscriberIdMigrationJob(
override fun performMigration() {
Currency.getAvailableCurrencies().forEach { currency ->
val subscriber = SignalStore.donations.getSubscriber(currency)
val subscriber = SignalStore.inAppPayments.getSubscriber(currency)
if (subscriber != null) {
SignalDatabase.inAppPaymentSubscribers.insertOrReplace(
@@ -39,8 +39,8 @@ internal class SubscriberIdMigrationJob(
subscriber.subscriberId,
subscriber.currency,
InAppPaymentSubscriberRecord.Type.DONATION,
SignalStore.donations.shouldCancelSubscriptionBeforeNextSubscribeAttempt,
SignalStore.donations.getSubscriptionPaymentSourceType().toPaymentMethodType()
SignalStore.inAppPayments.shouldCancelSubscriptionBeforeNextSubscribeAttempt,
SignalStore.inAppPayments.getSubscriptionPaymentSourceType().toPaymentMethodType()
)
)
}

View File

@@ -157,7 +157,7 @@ public final class StorageSyncHelper {
.setUniversalExpireTimer(SignalStore.settings().getUniversalExpireTimer())
.setDefaultReactions(SignalStore.emoji().getReactions())
.setSubscriber(StorageSyncModels.localToRemoteSubscriber(InAppPaymentsRepository.getSubscriber(InAppPaymentSubscriberRecord.Type.DONATION)))
.setDisplayBadgesOnProfile(SignalStore.donations().getDisplayBadgesOnProfile())
.setDisplayBadgesOnProfile(SignalStore.inAppPayments().getDisplayBadgesOnProfile())
.setSubscriptionManuallyCancelled(InAppPaymentsRepository.isUserManuallyCancelled(InAppPaymentSubscriberRecord.Type.DONATION))
.setKeepMutedChatsArchived(SignalStore.settings().shouldKeepMutedChatsArchived())
.setHasSetMyStoriesPrivacy(SignalStore.story().getUserHasBeenNotifiedAboutStories())
@@ -200,7 +200,7 @@ public final class StorageSyncHelper {
SignalStore.payments().setEnabledAndEntropy(update.getNew().getPayments().isEnabled(), Entropy.fromBytes(update.getNew().getPayments().getEntropy().orElse(null)));
SignalStore.settings().setUniversalExpireTimer(update.getNew().getUniversalExpireTimer());
SignalStore.emoji().setReactions(update.getNew().getDefaultReactions());
SignalStore.donations().setDisplayBadgesOnProfile(update.getNew().isDisplayBadgesOnProfile());
SignalStore.inAppPayments().setDisplayBadgesOnProfile(update.getNew().isDisplayBadgesOnProfile());
SignalStore.settings().setKeepMutedChatsArchived(update.getNew().isKeepMutedChatsArchived());
SignalStore.story().setUserHasBeenNotifiedAboutStories(update.getNew().hasSetMyStoriesPrivacy());
SignalStore.story().setUserHasViewedOnboardingStory(update.getNew().hasViewedOnboardingStory());
@@ -226,7 +226,7 @@ public final class StorageSyncHelper {
}
if (update.getNew().isSubscriptionManuallyCancelled() && !update.getOld().isSubscriptionManuallyCancelled()) {
SignalStore.donations().updateLocalStateForManualCancellation(InAppPaymentSubscriberRecord.Type.DONATION);
SignalStore.inAppPayments().updateLocalStateForManualCancellation(InAppPaymentSubscriberRecord.Type.DONATION);
}
if (fetchProfile && update.getNew().getAvatarUrlPath().isPresent()) {