]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/json/JsonDataMessage.java
Reformat code
[signal-cli] / src / main / java / org / asamk / signal / json / JsonDataMessage.java
index e755acad3b0ab72d6e094eac3e81bd519acfbd16..57facc99e6b87720ed4e2df024990bc1c174a345 100644 (file)
@@ -24,6 +24,10 @@ class JsonDataMessage {
     @JsonProperty
     final Integer expiresInSeconds;
 
+    @JsonProperty
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    final Boolean viewOnce;
+
     @JsonProperty
     @JsonInclude(JsonInclude.Include.NON_NULL)
     final JsonReaction reaction;
@@ -44,6 +48,14 @@ class JsonDataMessage {
     @JsonInclude(JsonInclude.Include.NON_NULL)
     final JsonSticker sticker;
 
+    @JsonProperty
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    final JsonRemoteDelete remoteDelete;
+
+    @JsonProperty
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    final List<JsonSharedContact> contacts;
+
     @JsonProperty
     @JsonInclude(JsonInclude.Include.NON_NULL)
     final JsonGroupInfo groupInfo;
@@ -66,6 +78,7 @@ class JsonDataMessage {
         }
         this.message = dataMessage.getBody().orNull();
         this.expiresInSeconds = dataMessage.getExpiresInSeconds();
+        this.viewOnce = dataMessage.isViewOnce();
         this.reaction = dataMessage.getReaction().isPresent()
                 ? new JsonReaction(dataMessage.getReaction().get(), m)
                 : null;
@@ -79,6 +92,8 @@ class JsonDataMessage {
         } else {
             this.mentions = List.of();
         }
+        remoteDelete = dataMessage.getRemoteDelete().isPresent() ? new JsonRemoteDelete(dataMessage.getRemoteDelete()
+                .get()) : null;
         if (dataMessage.getAttachments().isPresent()) {
             this.attachments = dataMessage.getAttachments()
                     .get()
@@ -89,6 +104,16 @@ class JsonDataMessage {
             this.attachments = List.of();
         }
         this.sticker = dataMessage.getSticker().isPresent() ? new JsonSticker(dataMessage.getSticker().get()) : null;
+
+        if (dataMessage.getSharedContacts().isPresent()) {
+            this.contacts = dataMessage.getSharedContacts()
+                    .get()
+                    .stream()
+                    .map(JsonSharedContact::new)
+                    .collect(Collectors.toList());
+        } else {
+            this.contacts = List.of();
+        }
     }
 
     public JsonDataMessage(Signal.MessageReceived messageReceived) {
@@ -96,10 +121,13 @@ class JsonDataMessage {
         message = messageReceived.getMessage();
         groupInfo = messageReceived.getGroupId().length > 0 ? new JsonGroupInfo(messageReceived.getGroupId()) : null;
         expiresInSeconds = null;
-        reaction = null;    // TODO Replace these 4 with the proper commands
+        viewOnce = null;
+        remoteDelete = null;
+        reaction = null;    // TODO Replace these 5 with the proper commands
         quote = null;
         mentions = null;
         sticker = null;
+        contacts = null;
         attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());
     }
 
@@ -108,10 +136,13 @@ class JsonDataMessage {
         message = messageReceived.getMessage();
         groupInfo = messageReceived.getGroupId().length > 0 ? new JsonGroupInfo(messageReceived.getGroupId()) : null;
         expiresInSeconds = null;
-        reaction = null;    // TODO Replace these 4 with the proper commands
+        viewOnce = null;
+        remoteDelete = null;
+        reaction = null;    // TODO Replace these 5 with the proper commands
         quote = null;
         mentions = null;
         sticker = null;
+        contacts = null;
         attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());
     }
 }