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
.Member
;
9 import org
.signal
.storageservice
.protos
.groups
.local
.DecryptedGroup
;
10 import org
.signal
.storageservice
.protos
.groups
.local
.EnabledState
;
11 import org
.signal
.zkgroup
.groups
.GroupMasterKey
;
12 import org
.whispersystems
.signalservice
.api
.push
.SignalServiceAddress
;
13 import org
.whispersystems
.signalservice
.api
.util
.UuidUtil
;
16 import java
.util
.stream
.Collectors
;
18 public class GroupInfoV2
extends GroupInfo
{
20 private final GroupIdV2 groupId
;
21 private final GroupMasterKey masterKey
;
23 private boolean blocked
;
24 private DecryptedGroup group
; // stored as a file with hexadecimal groupId as name
25 private RecipientResolver recipientResolver
;
27 public GroupInfoV2(final GroupIdV2 groupId
, final GroupMasterKey masterKey
) {
28 this.groupId
= groupId
;
29 this.masterKey
= masterKey
;
32 public GroupInfoV2(final GroupIdV2 groupId
, final GroupMasterKey masterKey
, final boolean blocked
) {
33 this.groupId
= groupId
;
34 this.masterKey
= masterKey
;
35 this.blocked
= blocked
;
39 public GroupIdV2
getGroupId() {
43 public GroupMasterKey
getMasterKey() {
47 public void setGroup(final DecryptedGroup group
, final RecipientResolver recipientResolver
) {
49 this.recipientResolver
= recipientResolver
;
52 public DecryptedGroup
getGroup() {
57 public String
getTitle() {
58 if (this.group
== null) {
61 return this.group
.getTitle();
65 public String
getDescription() {
66 if (this.group
== null) {
69 return this.group
.getDescription();
73 public GroupInviteLinkUrl
getGroupInviteLink() {
74 if (this.group
== null || this.group
.getInviteLinkPassword().isEmpty() || (
75 this.group
.getAccessControl().getAddFromInviteLink() != AccessControl
.AccessRequired
.ANY
76 && this.group
.getAccessControl().getAddFromInviteLink()
77 != AccessControl
.AccessRequired
.ADMINISTRATOR
82 return GroupInviteLinkUrl
.forGroup(masterKey
, group
);
86 public Set
<RecipientId
> getMembers() {
87 if (this.group
== null) {
90 return group
.getMembersList()
92 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
93 .map(recipientResolver
::resolveRecipient
)
94 .collect(Collectors
.toSet());
98 public Set
<RecipientId
> getPendingMembers() {
99 if (this.group
== null) {
102 return group
.getPendingMembersList()
104 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
105 .map(recipientResolver
::resolveRecipient
)
106 .collect(Collectors
.toSet());
110 public Set
<RecipientId
> getRequestingMembers() {
111 if (this.group
== null) {
114 return group
.getRequestingMembersList()
116 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
117 .map(recipientResolver
::resolveRecipient
)
118 .collect(Collectors
.toSet());
122 public Set
<RecipientId
> getAdminMembers() {
123 if (this.group
== null) {
126 return group
.getMembersList()
128 .filter(m
-> m
.getRole() == Member
.Role
.ADMINISTRATOR
)
129 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
130 .map(recipientResolver
::resolveRecipient
)
131 .collect(Collectors
.toSet());
135 public boolean isBlocked() {
140 public void setBlocked(final boolean blocked
) {
141 this.blocked
= blocked
;
145 public int getMessageExpirationTime() {
146 return this.group
!= null && this.group
.hasDisappearingMessagesTimer()
147 ?
this.group
.getDisappearingMessagesTimer().getDuration()
152 public boolean isAnnouncementGroup() {
153 return this.group
!= null && this.group
.getIsAnnouncementGroup() == EnabledState
.ENABLED
;