1 package org
.asamk
.signal
.json
;
3 import org
.asamk
.signal
.manager
.GroupUtils
;
4 import org
.whispersystems
.signalservice
.api
.messages
.SignalServiceGroup
;
5 import org
.whispersystems
.signalservice
.api
.messages
.SignalServiceGroupV2
;
6 import org
.whispersystems
.signalservice
.api
.push
.SignalServiceAddress
;
7 import org
.whispersystems
.util
.Base64
;
9 import java
.util
.ArrayList
;
10 import java
.util
.List
;
19 JsonGroupInfo(SignalServiceGroup groupInfo
) {
20 this.groupId
= Base64
.encodeBytes(groupInfo
.getGroupId());
21 if (groupInfo
.getMembers().isPresent()) {
22 this.members
= new ArrayList
<>(groupInfo
.getMembers().get().size());
23 for (SignalServiceAddress address
: groupInfo
.getMembers().get()) {
24 this.members
.add(address
.getLegacyIdentifier());
27 if (groupInfo
.getName().isPresent()) {
28 this.name
= groupInfo
.getName().get();
30 this.type
= groupInfo
.getType().toString();
33 JsonGroupInfo(SignalServiceGroupV2 groupInfo
) {
34 this.groupId
= GroupUtils
.getGroupIdV2(groupInfo
.getMasterKey()).toBase64();
35 this.type
= groupInfo
.hasSignedGroupChange() ?
"UPDATE" : "DELIVER";
38 JsonGroupInfo(byte[] groupId
) {
39 this.groupId
= Base64
.encodeBytes(groupId
);