Expand donation job logging.
This commit is contained in:
parent
db4a0deccc
commit
73d8c74718
4 changed files with 16 additions and 4 deletions
|
@ -160,9 +160,11 @@ class DonationPaymentRepository(activity: Activity) : StripeApi.PaymentIntentFet
|
|||
}
|
||||
}
|
||||
} else {
|
||||
Log.d(TAG, "Boost redemption timed out waiting for job completion.", true)
|
||||
it.onError(DonationExceptions.TimedOutWaitingForTokenRedemption)
|
||||
}
|
||||
} catch (e: InterruptedException) {
|
||||
Log.d(TAG, "Boost redemption job interrupted", e, true)
|
||||
it.onError(DonationExceptions.TimedOutWaitingForTokenRedemption)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
@ -45,8 +43,6 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
|
|||
|
||||
private final String paymentIntentId;
|
||||
|
||||
private boolean isPaymentFailure;
|
||||
|
||||
static BoostReceiptRequestResponseJob createJob(StripeApi.PaymentIntent paymentIntent) {
|
||||
return new BoostReceiptRequestResponseJob(
|
||||
new Parameters
|
||||
|
@ -105,6 +101,8 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
|
|||
@Override
|
||||
protected void onRun() throws Exception {
|
||||
if (requestContext == null) {
|
||||
Log.d(TAG, "Creating request context..");
|
||||
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] randomBytes = new byte[ReceiptSerial.SIZE];
|
||||
|
||||
|
@ -114,8 +112,11 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
|
|||
ClientZkReceiptOperations operations = ApplicationDependencies.getClientZkReceiptOperations();
|
||||
|
||||
requestContext = operations.createReceiptCredentialRequestContext(secureRandom, receiptSerial);
|
||||
} else {
|
||||
Log.d(TAG, "Reusing request context from previous run", true);
|
||||
}
|
||||
|
||||
Log.d(TAG, "Submitting credential to server", true);
|
||||
ServiceResponse<ReceiptCredentialResponse> response = ApplicationDependencies.getDonationsService()
|
||||
.submitBoostReceiptCredentialRequest(paymentIntentId, requestContext.getRequest())
|
||||
.blockingGet();
|
||||
|
@ -130,6 +131,7 @@ public class BoostReceiptRequestResponseJob extends BaseJob {
|
|||
throw new IOException("Could not validate receipt credential");
|
||||
}
|
||||
|
||||
Log.d(TAG, "Validated credential. Handing off to redemption job.", true);
|
||||
ReceiptCredentialPresentation receiptCredentialPresentation = getReceiptCredentialPresentation(receiptCredential);
|
||||
setOutputData(new Data.Builder().putBlobAsString(DonationReceiptRedemptionJob.INPUT_RECEIPT_CREDENTIAL_PRESENTATION,
|
||||
receiptCredentialPresentation.serialize())
|
||||
|
|
|
@ -77,6 +77,7 @@ public class DonationReceiptRedemptionJob extends BaseJob {
|
|||
}
|
||||
|
||||
if (isForSubscription()) {
|
||||
Log.d(TAG, "Marking subscription failure", true);
|
||||
SignalStore.donationsValues().markSubscriptionRedemptionFailed();
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +103,7 @@ public class DonationReceiptRedemptionJob extends BaseJob {
|
|||
|
||||
ReceiptCredentialPresentation presentation = new ReceiptCredentialPresentation(presentationBytes);
|
||||
|
||||
Log.d(TAG, "Attempting to redeem token... isForSubscription: " + isForSubscription(), true);
|
||||
ServiceResponse<EmptyResponse> response = ApplicationDependencies.getDonationsService()
|
||||
.redeemReceipt(presentation,
|
||||
SignalStore.donationsValues().getDisplayBadgesOnProfile(),
|
||||
|
@ -122,6 +124,7 @@ public class DonationReceiptRedemptionJob extends BaseJob {
|
|||
}
|
||||
|
||||
if (isForSubscription()) {
|
||||
Log.d(TAG, "Clearing subscription failure", true);
|
||||
SignalStore.donationsValues().clearSubscriptionRedemptionFailed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
|
|||
}
|
||||
|
||||
if (requestContext == null) {
|
||||
Log.d(TAG, "Generating request credentials context for token redemption...", true);
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] randomBytes = new byte[ReceiptSerial.SIZE];
|
||||
|
||||
|
@ -133,8 +134,11 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
|
|||
ClientZkReceiptOperations operations = ApplicationDependencies.getClientZkReceiptOperations();
|
||||
|
||||
requestContext = operations.createReceiptCredentialRequestContext(secureRandom, receiptSerial);
|
||||
} else {
|
||||
Log.d(TAG, "Already have credentials generated for this request. Retrying web service call...", true);
|
||||
}
|
||||
|
||||
Log.d(TAG, "Submitting receipt credential request.");
|
||||
ServiceResponse<ReceiptCredentialResponse> response = ApplicationDependencies.getDonationsService()
|
||||
.submitReceiptCredentialRequest(subscriberId, requestContext.getRequest())
|
||||
.blockingGet();
|
||||
|
@ -152,6 +156,7 @@ public class SubscriptionReceiptRequestResponseJob extends BaseJob {
|
|||
throw new IOException("Could not validate receipt credential");
|
||||
}
|
||||
|
||||
Log.d(TAG, "Validated credential. Handing off to redemption job.", true);
|
||||
ReceiptCredentialPresentation receiptCredentialPresentation = getReceiptCredentialPresentation(receiptCredential);
|
||||
setOutputData(new Data.Builder().putBlobAsString(DonationReceiptRedemptionJob.INPUT_RECEIPT_CREDENTIAL_PRESENTATION,
|
||||
receiptCredentialPresentation.serialize())
|
||||
|
|
Loading…
Add table
Reference in a new issue