Search in sources :

Example 1 with PaymentTransactionCheckJob

use of org.thoughtcrime.securesms.jobs.PaymentTransactionCheckJob in project Signal-Android by WhisperSystems.

the class MessageContentProcessor method handlePayment.

private void handlePayment(@NonNull SignalServiceContent content, @NonNull SignalServiceDataMessage message, @NonNull Recipient senderRecipient) {
    log(content.getTimestamp(), "Payment message.");
    if (!message.getPayment().isPresent()) {
        throw new AssertionError();
    }
    if (!message.getPayment().get().getPaymentNotification().isPresent()) {
        warn(content.getTimestamp(), "Ignoring payment message without notification");
        return;
    }
    SignalServiceDataMessage.PaymentNotification paymentNotification = message.getPayment().get().getPaymentNotification().get();
    PaymentDatabase paymentDatabase = SignalDatabase.payments();
    UUID uuid = UUID.randomUUID();
    String queue = "Payment_" + PushProcessMessageJob.getQueueName(senderRecipient.getId());
    try {
        paymentDatabase.createIncomingPayment(uuid, senderRecipient.getId(), message.getTimestamp(), paymentNotification.getNote(), Money.MobileCoin.ZERO, Money.MobileCoin.ZERO, paymentNotification.getReceipt());
    } catch (PaymentDatabase.PublicKeyConflictException e) {
        warn(content.getTimestamp(), "Ignoring payment with public key already in database");
        return;
    } catch (SerializationException e) {
        warn(content.getTimestamp(), "Ignoring payment with bad data.", e);
    }
    ApplicationDependencies.getJobManager().startChain(new PaymentTransactionCheckJob(uuid, queue)).then(PaymentLedgerUpdateJob.updateLedger()).enqueue();
}
Also used : SignalServiceDataMessage(org.whispersystems.signalservice.api.messages.SignalServiceDataMessage) SerializationException(com.mobilecoin.lib.exceptions.SerializationException) PaymentDatabase(org.thoughtcrime.securesms.database.PaymentDatabase) UUID(java.util.UUID) PaymentTransactionCheckJob(org.thoughtcrime.securesms.jobs.PaymentTransactionCheckJob)

Example 2 with PaymentTransactionCheckJob

use of org.thoughtcrime.securesms.jobs.PaymentTransactionCheckJob in project Signal-Android by signalapp.

the class MessageContentProcessor method handlePayment.

private void handlePayment(@NonNull SignalServiceContent content, @NonNull SignalServiceDataMessage message, @NonNull Recipient senderRecipient) {
    log(content.getTimestamp(), "Payment message.");
    if (!message.getPayment().isPresent()) {
        throw new AssertionError();
    }
    if (!message.getPayment().get().getPaymentNotification().isPresent()) {
        warn(content.getTimestamp(), "Ignoring payment message without notification");
        return;
    }
    SignalServiceDataMessage.PaymentNotification paymentNotification = message.getPayment().get().getPaymentNotification().get();
    PaymentDatabase paymentDatabase = SignalDatabase.payments();
    UUID uuid = UUID.randomUUID();
    String queue = "Payment_" + PushProcessMessageJob.getQueueName(senderRecipient.getId());
    try {
        paymentDatabase.createIncomingPayment(uuid, senderRecipient.getId(), message.getTimestamp(), paymentNotification.getNote(), Money.MobileCoin.ZERO, Money.MobileCoin.ZERO, paymentNotification.getReceipt());
    } catch (PaymentDatabase.PublicKeyConflictException e) {
        warn(content.getTimestamp(), "Ignoring payment with public key already in database");
        return;
    } catch (SerializationException e) {
        warn(content.getTimestamp(), "Ignoring payment with bad data.", e);
    }
    ApplicationDependencies.getJobManager().startChain(new PaymentTransactionCheckJob(uuid, queue)).then(PaymentLedgerUpdateJob.updateLedger()).enqueue();
}
Also used : SignalServiceDataMessage(org.whispersystems.signalservice.api.messages.SignalServiceDataMessage) SerializationException(com.mobilecoin.lib.exceptions.SerializationException) PaymentDatabase(org.thoughtcrime.securesms.database.PaymentDatabase) UUID(java.util.UUID) PaymentTransactionCheckJob(org.thoughtcrime.securesms.jobs.PaymentTransactionCheckJob)

Aggregations

SerializationException (com.mobilecoin.lib.exceptions.SerializationException)2 UUID (java.util.UUID)2 PaymentDatabase (org.thoughtcrime.securesms.database.PaymentDatabase)2 PaymentTransactionCheckJob (org.thoughtcrime.securesms.jobs.PaymentTransactionCheckJob)2 SignalServiceDataMessage (org.whispersystems.signalservice.api.messages.SignalServiceDataMessage)2