add JsonPayment (#808)

This commit is contained in:
technillogue 2021-11-23 02:14:01 -05:00 committed by GitHub
parent d13d150fe1
commit 5cd5697aea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 0 deletions

View file

@ -101,6 +101,7 @@ public record MessageEnvelope(
boolean hasProfileKey,
Optional<Reaction> reaction,
Optional<Quote> quote,
Optional<Payment> payment,
List<Attachment> attachments,
Optional<Long> remoteDeleteId,
Optional<Sticker> sticker,
@ -130,6 +131,9 @@ public record MessageEnvelope(
Optional.ofNullable(dataMessage.getQuote()
.transform(q -> Quote.from(q, recipientResolver, addressResolver, fileProvider))
.orNull()),
Optional.ofNullable(dataMessage.getPayment()
.transform(p -> p.getPaymentNotification().isPresent() ? Payment.from(p) : null)
.orNull()),
dataMessage.getAttachments()
.transform(a -> a.stream()
.map(as -> Attachment.from(as, fileProvider))
@ -229,6 +233,12 @@ public record MessageEnvelope(
}
}
public record Payment(String note, byte[] receipt) {
static Payment from(SignalServiceDataMessage.Payment payment) {
return new Payment(payment.getPaymentNotification().get().getNote(), payment.getPaymentNotification().get().getReceipt());
}
}
public record Mention(RecipientAddress recipient, int start, int length) {
static Mention from(