From 7e267f1ebb17dd8e6b9ea007c2d65305fea0fb05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fern=C3=A1ndez=20Vald=C3=A9s?= Date: Mon, 23 Sep 2019 12:31:55 -0400 Subject: [PATCH] Added ReceiptMessage to JSON output --- .../org/asamk/signal/JsonMessageEnvelope.java | 4 +++ .../org/asamk/signal/JsonReceiptMessage.java | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/main/java/org/asamk/signal/JsonReceiptMessage.java diff --git a/src/main/java/org/asamk/signal/JsonMessageEnvelope.java b/src/main/java/org/asamk/signal/JsonMessageEnvelope.java index 9971b011..e7003130 100644 --- a/src/main/java/org/asamk/signal/JsonMessageEnvelope.java +++ b/src/main/java/org/asamk/signal/JsonMessageEnvelope.java @@ -14,6 +14,7 @@ class JsonMessageEnvelope { JsonDataMessage dataMessage; JsonSyncMessage syncMessage; JsonCallMessage callMessage; + JsonReceiptMessage receiptMessage; public JsonMessageEnvelope(SignalServiceEnvelope envelope, SignalServiceContent content) { SignalServiceAddress source = envelope.getSourceAddress(); @@ -32,6 +33,9 @@ class JsonMessageEnvelope { if (content.getCallMessage().isPresent()) { this.callMessage = new JsonCallMessage(content.getCallMessage().get()); } + if (content.getReceiptMessage().isPresent()) { + this.receiptMessage = new JsonReceiptMessage(content.getReceiptMessage().get()); + } } } } diff --git a/src/main/java/org/asamk/signal/JsonReceiptMessage.java b/src/main/java/org/asamk/signal/JsonReceiptMessage.java new file mode 100644 index 00000000..fd875af5 --- /dev/null +++ b/src/main/java/org/asamk/signal/JsonReceiptMessage.java @@ -0,0 +1,25 @@ +package org.asamk.signal; + +import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage; + +import java.util.List; + +class JsonReceiptMessage { + + long when; + boolean isDelivery; + boolean isRead; + List timestamps; + + JsonReceiptMessage(SignalServiceReceiptMessage receiptMessage) { + + this.when = receiptMessage.getWhen(); + if (receiptMessage.isDeliveryReceipt()) { + this.isDelivery = true; + } + if (receiptMessage.isReadReceipt()) { + this.isRead = true; + } + this.timestamps = receiptMessage.getTimestamps(); + } +}