1 package org
.asamk
.signal
.manager
.storage
.groups
;
3 import org
.asamk
.signal
.manager
.groups
.GroupIdV2
;
4 import org
.asamk
.signal
.manager
.groups
.GroupInviteLinkUrl
;
5 import org
.asamk
.signal
.manager
.storage
.recipients
.RecipientId
;
6 import org
.asamk
.signal
.manager
.storage
.recipients
.RecipientResolver
;
7 import org
.signal
.storageservice
.protos
.groups
.AccessControl
;
8 import org
.signal
.storageservice
.protos
.groups
.local
.DecryptedGroup
;
9 import org
.signal
.zkgroup
.groups
.GroupMasterKey
;
10 import org
.whispersystems
.signalservice
.api
.push
.SignalServiceAddress
;
11 import org
.whispersystems
.signalservice
.api
.util
.UuidUtil
;
14 import java
.util
.stream
.Collectors
;
16 public class GroupInfoV2
extends GroupInfo
{
18 private final GroupIdV2 groupId
;
19 private final GroupMasterKey masterKey
;
21 private boolean blocked
;
22 private DecryptedGroup group
; // stored as a file with hexadecimal groupId as name
23 private RecipientResolver recipientResolver
;
25 public GroupInfoV2(final GroupIdV2 groupId
, final GroupMasterKey masterKey
) {
26 this.groupId
= groupId
;
27 this.masterKey
= masterKey
;
30 public GroupInfoV2(final GroupIdV2 groupId
, final GroupMasterKey masterKey
, final boolean blocked
) {
31 this.groupId
= groupId
;
32 this.masterKey
= masterKey
;
33 this.blocked
= blocked
;
37 public GroupIdV2
getGroupId() {
41 public GroupMasterKey
getMasterKey() {
45 public void setGroup(final DecryptedGroup group
, final RecipientResolver recipientResolver
) {
47 this.recipientResolver
= recipientResolver
;
50 public DecryptedGroup
getGroup() {
55 public String
getTitle() {
56 if (this.group
== null) {
59 return this.group
.getTitle();
63 public GroupInviteLinkUrl
getGroupInviteLink() {
64 if (this.group
== null || this.group
.getInviteLinkPassword() == null || (
65 this.group
.getAccessControl().getAddFromInviteLink() != AccessControl
.AccessRequired
.ANY
66 && this.group
.getAccessControl().getAddFromInviteLink()
67 != AccessControl
.AccessRequired
.ADMINISTRATOR
72 return GroupInviteLinkUrl
.forGroup(masterKey
, group
);
76 public Set
<RecipientId
> getMembers() {
77 if (this.group
== null) {
80 return group
.getMembersList()
82 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
83 .map(recipientResolver
::resolveRecipient
)
84 .collect(Collectors
.toSet());
88 public Set
<RecipientId
> getPendingMembers() {
89 if (this.group
== null) {
92 return group
.getPendingMembersList()
94 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
95 .map(recipientResolver
::resolveRecipient
)
96 .collect(Collectors
.toSet());
100 public Set
<RecipientId
> getRequestingMembers() {
101 if (this.group
== null) {
104 return group
.getRequestingMembersList()
106 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
107 .map(recipientResolver
::resolveRecipient
)
108 .collect(Collectors
.toSet());
112 public boolean isBlocked() {
117 public void setBlocked(final boolean blocked
) {
118 this.blocked
= blocked
;
122 public int getMessageExpirationTime() {
123 return this.group
!= null && this.group
.hasDisappearingMessagesTimer()
124 ?
this.group
.getDisappearingMessagesTimer().getDuration()