]> nmode's Git Repositories - signal-cli/commitdiff
Added sticker field to json output. Also added hidden mac file to .gitignore (#418)
authorAtomic-Bean <75401809+Atomic-Bean@users.noreply.github.com>
Thu, 14 Jan 2021 17:10:35 +0000 (03:40 +1030)
committerGitHub <noreply@github.com>
Thu, 14 Jan 2021 17:10:35 +0000 (18:10 +0100)
.gitignore
src/main/java/org/asamk/signal/json/JsonDataMessage.java
src/main/java/org/asamk/signal/json/JsonSticker.java [new file with mode: 0644]

index 3dc9875b310761374197955c10327d4ed2f4d7f4..8fa9c8bd03ed0e924cf87e943fbd56a14a8094e2 100644 (file)
@@ -10,3 +10,4 @@ local.properties
 .project
 .settings/
 out/
+.DS_Store
index 57201eda7c68f1553ec7c6783b3c04044c4c9ec8..787f47abb79a4434327ef01b858ee68b9f6529b6 100644 (file)
@@ -19,6 +19,7 @@ class JsonDataMessage {
     JsonQuote quote;
     List<JsonMention> mentions;
     List<JsonAttachment> attachments;
+    JsonSticker sticker;
     JsonGroupInfo groupInfo;
 
     JsonDataMessage(SignalServiceDataMessage dataMessage, Manager m) {
@@ -60,15 +61,19 @@ class JsonDataMessage {
         } else {
             this.attachments = List.of();
         }
+        if (dataMessage.getSticker().isPresent()) {
+            this.sticker = new JsonSticker(dataMessage.getSticker().get());
+        }
     }
 
     public JsonDataMessage(Signal.MessageReceived messageReceived) {
         timestamp = messageReceived.getTimestamp();
         message = messageReceived.getMessage();
         groupInfo = new JsonGroupInfo(messageReceived.getGroupId());
-        reaction = null;    // TODO Replace these 3 with the proper commands
+        reaction = null;    // TODO Replace these 4 with the proper commands
         quote = null;
         mentions = null;
+        sticker = null;
         attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());
     }
 
@@ -76,9 +81,10 @@ class JsonDataMessage {
         timestamp = messageReceived.getTimestamp();
         message = messageReceived.getMessage();
         groupInfo = new JsonGroupInfo(messageReceived.getGroupId());
-        reaction = null;    // TODO Replace these 3 with the proper commands
+        reaction = null;    // TODO Replace these 4 with the proper commands
         quote = null;
         mentions = null;
+        sticker = null;
         attachments = messageReceived.getAttachments().stream().map(JsonAttachment::new).collect(Collectors.toList());
     }
 }
diff --git a/src/main/java/org/asamk/signal/json/JsonSticker.java b/src/main/java/org/asamk/signal/json/JsonSticker.java
new file mode 100644 (file)
index 0000000..228d288
--- /dev/null
@@ -0,0 +1,18 @@
+package org.asamk.signal.json;
+
+import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
+import org.whispersystems.util.Base64;
+
+public class JsonSticker {
+
+    String packId;
+    String packKey;
+    int stickerId;
+
+    public JsonSticker(SignalServiceDataMessage.Sticker sticker) {
+        this.packId = Base64.encodeBytes(sticker.getPackId());
+        this.packKey = Base64.encodeBytes(sticker.getPackKey());
+        this.stickerId = sticker.getStickerId();
+        // TODO also download sticker image ??
+    }
+}