Add several registered checks.

This commit is contained in:
Alex Hart
2025-03-18 09:42:15 -03:00
committed by Cody Henthorne
parent 076b47e695
commit 629f5a3a3d
3 changed files with 16 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobmanager.JobManager.Chain
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.whispersystems.signalservice.internal.ServiceResponse
import org.whispersystems.signalservice.internal.push.exceptions.InAppPaymentReceiptCredentialError
import java.io.IOException
@@ -112,6 +113,11 @@ class InAppPaymentOneTimeContextJob private constructor(
}
override fun onRun() {
if (!SignalStore.account.isRegistered) {
warning("User is not registered. Failing.")
throw Exception("Unregistered users cannot perform this job.")
}
val (inAppPayment, requestContext) = getAndValidateInAppPayment()
info("Submitting request context to server...")

View File

@@ -140,6 +140,11 @@ class InAppPaymentRecurringContextJob private constructor(
}
private fun doRun() {
if (!SignalStore.account.isRegistered) {
warning("User is not registered. Failing.")
throw Exception("Unregistered users cannot perform this job.")
}
val (inAppPayment, requestContext) = getAndValidateInAppPayment()
val activeSubscription = getActiveSubscription(inAppPayment)
val subscription = activeSubscription.activeSubscription

View File

@@ -142,6 +142,11 @@ class InAppPaymentRedemptionJob private constructor(
}
override fun onRun() {
if (!SignalStore.account.isRegistered) {
Log.w(TAG, "User is not registered. Failing.")
throw Exception("Unregistered users cannot perform this job.")
}
if (jobData.inAppPaymentId != null) {
onRunForInAppPayment(InAppPaymentTable.InAppPaymentId(jobData.inAppPaymentId))
} else {