mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Output json when receiving messages from dbus and --json parameter is given
Fixes #138
This commit is contained in:
parent
e04c45766d
commit
ae41d0c502
15 changed files with 176 additions and 50 deletions
34
src/main/java/org/asamk/signal/json/JsonGroupInfo.java
Normal file
34
src/main/java/org/asamk/signal/json/JsonGroupInfo.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package org.asamk.signal.json;
|
||||
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceGroup;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.util.Base64;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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 = new ArrayList<>(groupInfo.getMembers().get().size());
|
||||
for (SignalServiceAddress address : groupInfo.getMembers().get()) {
|
||||
this.members.add(address.getNumber().get());
|
||||
}
|
||||
}
|
||||
if (groupInfo.getName().isPresent()) {
|
||||
this.name = groupInfo.getName().get();
|
||||
}
|
||||
this.type = groupInfo.getType().toString();
|
||||
}
|
||||
|
||||
JsonGroupInfo(byte[] groupId) {
|
||||
this.groupId = Base64.encodeBytes(groupId);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue