mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-27 05:03:28 +00:00
Add check for authorized job. Fix issue with start external activity error propagation.
This commit is contained in:
committed by
Greyson Parrelli
parent
02d4b1897e
commit
d7221a384b
@@ -20,10 +20,8 @@ import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.Completable
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.core.util.concurrent.LifecycleDisposable
|
||||
import org.signal.core.util.concurrent.SignalExecutors
|
||||
import org.signal.donations.StripeIntentAccessor
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.ViewBinderDelegate
|
||||
@@ -106,20 +104,17 @@ class Stripe3DSDialogFragment : DialogFragment(R.layout.donation_webview_fragmen
|
||||
}
|
||||
|
||||
private fun handleLaunchExternal(intent: Intent) {
|
||||
lifecycleDisposable += Completable
|
||||
.fromAction {
|
||||
SignalDatabase.inAppPayments.update(args.inAppPayment)
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
result = bundleOf(
|
||||
LAUNCHED_EXTERNAL to true
|
||||
)
|
||||
startActivity(intent)
|
||||
|
||||
startActivity(intent)
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
SignalExecutors.BOUNDED_IO.execute {
|
||||
SignalDatabase.inAppPayments.update(args.inAppPayment)
|
||||
}
|
||||
|
||||
result = bundleOf(
|
||||
LAUNCHED_EXTERNAL to true
|
||||
)
|
||||
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
private inner class Stripe3DSWebClient : WebViewClient() {
|
||||
|
||||
@@ -173,7 +173,7 @@ class InAppPaymentAuthCheckJob private constructor(parameters: Parameters) : Bas
|
||||
|
||||
Log.i(TAG, "Enqueuing job chain.")
|
||||
val updatedPayment = SignalDatabase.inAppPayments.getById(inAppPayment.id)
|
||||
InAppPaymentOneTimeContextJob.createJobChain(updatedPayment!!).enqueue()
|
||||
InAppPaymentOneTimeContextJob.createJobChain(updatedPayment!!, isFromAuthCheck = true).enqueue()
|
||||
return CheckResult.Success(Unit)
|
||||
}
|
||||
|
||||
|
||||
@@ -57,12 +57,12 @@ class InAppPaymentOneTimeContextJob private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
fun createJobChain(inAppPayment: InAppPaymentTable.InAppPayment, makePrimary: Boolean = false): Chain {
|
||||
fun createJobChain(inAppPayment: InAppPaymentTable.InAppPayment, makePrimary: Boolean = false, isFromAuthCheck: Boolean = false): Chain {
|
||||
return when (inAppPayment.type) {
|
||||
InAppPaymentType.ONE_TIME_DONATION -> {
|
||||
AppDependencies.jobManager
|
||||
.startChain(create(inAppPayment))
|
||||
.then(InAppPaymentRedemptionJob.create(inAppPayment, makePrimary))
|
||||
.then(InAppPaymentRedemptionJob.create(inAppPayment = inAppPayment, makePrimary = makePrimary, isFromAuthCheck = isFromAuthCheck))
|
||||
.then(RefreshOwnProfileJob())
|
||||
.then(MultiDeviceProfileContentUpdateJob())
|
||||
}
|
||||
|
||||
@@ -59,12 +59,14 @@ class InAppPaymentRedemptionJob private constructor(
|
||||
|
||||
fun create(
|
||||
inAppPayment: InAppPaymentTable.InAppPayment? = null,
|
||||
makePrimary: Boolean = false
|
||||
makePrimary: Boolean = false,
|
||||
isFromAuthCheck: Boolean = false
|
||||
): Job {
|
||||
return create(
|
||||
inAppPayment = inAppPayment,
|
||||
giftMessageId = null,
|
||||
makePrimary = makePrimary
|
||||
makePrimary = makePrimary,
|
||||
isFromAuthCheck = isFromAuthCheck
|
||||
)
|
||||
}
|
||||
|
||||
@@ -82,13 +84,15 @@ class InAppPaymentRedemptionJob private constructor(
|
||||
private fun create(
|
||||
inAppPayment: InAppPaymentTable.InAppPayment? = null,
|
||||
makePrimary: Boolean = false,
|
||||
isFromAuthCheck: Boolean = false,
|
||||
giftMessageId: MessageId? = null
|
||||
): Job {
|
||||
return InAppPaymentRedemptionJob(
|
||||
jobData = InAppPaymentRedemptionJobData(
|
||||
inAppPaymentId = inAppPayment?.id?.rowId,
|
||||
giftMessageId = giftMessageId?.id,
|
||||
makePrimary = makePrimary
|
||||
makePrimary = makePrimary,
|
||||
isFromAuthCheck = isFromAuthCheck
|
||||
),
|
||||
parameters = Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
@@ -243,9 +247,11 @@ class InAppPaymentRedemptionJob private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
Log.i(TAG, "InAppPayment with ID $inAppPaymentId was successfully redeemed. Response code: ${serviceResponse.status}")
|
||||
Log.i(TAG, "InAppPayment with ID $inAppPaymentId was successfully redeemed. Response code: ${serviceResponse.status}, Will notify: ${jobData.isFromAuthCheck}")
|
||||
|
||||
SignalDatabase.inAppPayments.update(
|
||||
inAppPayment = inAppPayment.copy(
|
||||
notified = !jobData.isFromAuthCheck,
|
||||
state = InAppPaymentTable.State.END,
|
||||
data = inAppPayment.data.copy(
|
||||
redemption = inAppPayment.data.redemption.copy(
|
||||
|
||||
Reference in New Issue
Block a user