mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-08-14 01:03:28 +01:00
Fully allow donations from linked devices.
This commit is contained in:
+2
-2
@@ -154,9 +154,9 @@ class InAppPaymentRecurringContextJob private constructor(
|
||||
throw Exception("Unregistered users cannot perform this job.")
|
||||
}
|
||||
|
||||
if (SignalStore.account.isLinkedDevice) {
|
||||
if (SignalStore.account.isLinkedDevice && SignalDatabase.inAppPayments.getById(inAppPaymentId)?.type == InAppPaymentType.RECURRING_BACKUP) {
|
||||
warning("Linked device. Failing.")
|
||||
throw Exception("Linked devices cannot not perform this job")
|
||||
throw Exception("Linked devices cannot perform this job for backups")
|
||||
}
|
||||
|
||||
val (inAppPayment, requestContext) = getAndValidateInAppPayment()
|
||||
|
||||
+31
@@ -171,6 +171,37 @@ class InAppPaymentRecurringContextJobTest {
|
||||
assertThat(result.isSuccess).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given a linked device, when I run for a donation, then I expect success`() {
|
||||
every { mockSignalStore.account.isLinkedDevice } returns true
|
||||
|
||||
val activeSubscription = inAppPaymentsTestRule.createActiveSubscription()
|
||||
inAppPaymentsTestRule.initializeActiveSubscriptionMock(activeSubscription = activeSubscription)
|
||||
|
||||
val iap = insertInAppPayment()
|
||||
val job = InAppPaymentRecurringContextJob.create(iap)
|
||||
job.onAdded()
|
||||
|
||||
val result = job.run()
|
||||
assertThat(result.isSuccess).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given a linked device, when I run for a backup, then I expect failure`() {
|
||||
every { mockSignalStore.account.isLinkedDevice } returns true
|
||||
|
||||
val activeSubscription = inAppPaymentsTestRule.createActiveSubscription()
|
||||
inAppPaymentsTestRule.initializeActiveSubscriptionMock(activeSubscription = activeSubscription)
|
||||
|
||||
val iap = insertInAppPayment(type = InAppPaymentType.RECURRING_BACKUP)
|
||||
val job = InAppPaymentRecurringContextJob.create(iap)
|
||||
job.onAdded()
|
||||
|
||||
val result = job.run()
|
||||
assertThat(result.isFailure).isTrue()
|
||||
verify(atLeast = 0, atMost = 0) { AppDependencies.donationsService.submitReceiptCredentialRequestSync(any(), any()) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given END state, when I run, then I expect failure`() {
|
||||
val iap = insertInAppPayment(
|
||||
|
||||
Reference in New Issue
Block a user