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

@ -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());
}
}