]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/JsonGroupInfo.java
Implement json output for receive
[signal-cli] / src / main / java / org / asamk / signal / JsonGroupInfo.java
diff --git a/src/main/java/org/asamk/signal/JsonGroupInfo.java b/src/main/java/org/asamk/signal/JsonGroupInfo.java
new file mode 100644 (file)
index 0000000..89c5515
--- /dev/null
@@ -0,0 +1,24 @@
+package org.asamk.signal;
+
+import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
+import org.whispersystems.signalservice.internal.util.Base64;
+
+import java.util.List;
+
+class JsonGroupInfo {
+    String groupId;
+    List<String> members;
+    String name;
+    String type;
+
+    JsonGroupInfo(SignalServiceGroup groupInfo) {
+        this.groupId = Base64.encodeBytes(groupInfo.getGroupId());
+        if (groupInfo.getMembers().isPresent()) {
+            this.members = groupInfo.getMembers().get();
+        }
+        if (groupInfo.getName().isPresent()) {
+            this.name = groupInfo.getName().get();
+        }
+        this.type = groupInfo.getType().toString();
+    }
+}