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

@ -538,6 +538,16 @@
"allDeclaredMethods":true,
"allDeclaredConstructors":true}
,
{
"name":"org.asamk.signal.json.JsonPayment",
"allDeclaredFields":true,
"queryAllDeclaredMethods":true,
"queryAllDeclaredConstructors":true,
"methods":[
{"name":"note","parameterTypes":[] },
{"name":"receipt","parameterTypes":[] }
]}
,
{
"name":"org.asamk.signal.json.JsonQuote",
"allDeclaredFields":true,
@ -2216,6 +2226,29 @@
{"name":"eraId_"}
]}
,
{
"name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$DataMessage$Payment",
"fields":[
{"name":"itemCase_"},
{"name":"item_"}
]}
,
{
"name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$DataMessage$Payment$Notification",
"fields":[
{"name":"bitField0_"},
{"name":"note_"},
{"name":"transactionCase_"},
{"name":"transaction_"}
]}
,
{
"name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$DataMessage$Payment$Notification$MobileCoin",
"fields":[
{"name":"bitField0_"},
{"name":"receipt_"}
]}
,
{
"name":"org.whispersystems.signalservice.internal.push.SignalServiceProtos$DataMessage$Preview",
"fields":[

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(

View file

@ -680,6 +680,7 @@ public class DbusManagerImpl implements Manager {
false,
Optional.empty(),
Optional.empty(),
Optional.empty(),
getAttachments(extras),
Optional.empty(),
Optional.empty(),
@ -749,6 +750,7 @@ public class DbusManagerImpl implements Manager {
false,
Optional.empty(),
Optional.empty(),
Optional.empty(),
getAttachments(extras),
Optional.empty(),
Optional.empty(),

View file

@ -15,6 +15,7 @@ record JsonDataMessage(
@JsonInclude(JsonInclude.Include.NON_NULL) Boolean viewOnce,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonReaction reaction,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonQuote quote,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonPayment payment,
@JsonInclude(JsonInclude.Include.NON_NULL) List<JsonMention> mentions,
@JsonInclude(JsonInclude.Include.NON_NULL) List<JsonAttachment> attachments,
@JsonInclude(JsonInclude.Include.NON_NULL) JsonSticker sticker,
@ -32,6 +33,7 @@ record JsonDataMessage(
final var viewOnce = dataMessage.isViewOnce();
final var reaction = dataMessage.reaction().map(JsonReaction::from).orElse(null);
final var quote = dataMessage.quote().isPresent() ? JsonQuote.from(dataMessage.quote().get()) : null;
final var payment = dataMessage.payment().isPresent() ? JsonPayment.from(dataMessage.payment().get()) : null;
final var mentions = dataMessage.mentions().size() > 0 ? dataMessage.mentions()
.stream()
.map(JsonMention::from)
@ -55,6 +57,7 @@ record JsonDataMessage(
viewOnce,
reaction,
quote,
payment,
mentions,
attachments,
sticker,
@ -72,6 +75,7 @@ record JsonDataMessage(
null,
null,
null,
null,
messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
null,
null,
@ -88,6 +92,7 @@ record JsonDataMessage(
null,
null,
null,
null,
messageReceived.getAttachments().stream().map(JsonAttachment::from).collect(Collectors.toList()),
null,
null,

View file

@ -0,0 +1,9 @@
package org.asamk.signal.json;
import org.asamk.signal.manager.api.MessageEnvelope;
public record JsonPayment(String note, byte[] receipt) {
static JsonPayment from(MessageEnvelope.Data.Payment payment) {
return new JsonPayment(payment.note(), payment.receipt());
}
}