]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/storage/groups/GroupInfoV2.java
65f8c9a49ae0f14cfbf6b9fd036dca39bc41843c
1 package org
.asamk
.signal
.storage
.groups
;
3 import org
.asamk
.signal
.manager
.GroupInviteLinkUrl
;
4 import org
.signal
.storageservice
.protos
.groups
.AccessControl
;
5 import org
.signal
.storageservice
.protos
.groups
.local
.DecryptedGroup
;
6 import org
.signal
.zkgroup
.groups
.GroupMasterKey
;
7 import org
.whispersystems
.signalservice
.api
.push
.SignalServiceAddress
;
8 import org
.whispersystems
.signalservice
.api
.util
.UuidUtil
;
10 import java
.util
.Collections
;
12 import java
.util
.stream
.Collectors
;
14 public class GroupInfoV2
extends GroupInfo
{
16 private final GroupMasterKey masterKey
;
18 private boolean blocked
;
19 private DecryptedGroup group
; // stored as a file with hexadecimal groupId as name
21 public GroupInfoV2(final byte[] groupId
, final GroupMasterKey masterKey
) {
23 this.masterKey
= masterKey
;
26 public GroupMasterKey
getMasterKey() {
30 public void setGroup(final DecryptedGroup group
) {
34 public DecryptedGroup
getGroup() {
39 public String
getTitle() {
40 if (this.group
== null) {
43 return this.group
.getTitle();
47 public GroupInviteLinkUrl
getGroupInviteLink() {
48 if (this.group
== null || this.group
.getInviteLinkPassword() == null || (
49 this.group
.getAccessControl().getAddFromInviteLink() != AccessControl
.AccessRequired
.ANY
50 && this.group
.getAccessControl().getAddFromInviteLink()
51 != AccessControl
.AccessRequired
.ADMINISTRATOR
56 return GroupInviteLinkUrl
.forGroup(masterKey
, group
);
60 public Set
<SignalServiceAddress
> getMembers() {
61 if (this.group
== null) {
62 return Collections
.emptySet();
64 return group
.getMembersList()
66 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
67 .collect(Collectors
.toSet());
71 public Set
<SignalServiceAddress
> getPendingMembers() {
72 if (this.group
== null) {
73 return Collections
.emptySet();
75 return group
.getPendingMembersList()
77 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
78 .collect(Collectors
.toSet());
82 public Set
<SignalServiceAddress
> getRequestingMembers() {
83 if (this.group
== null) {
84 return Collections
.emptySet();
86 return group
.getRequestingMembersList()
88 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
89 .collect(Collectors
.toSet());
93 public boolean isBlocked() {
98 public void setBlocked(final boolean blocked
) {
99 this.blocked
= blocked
;
103 public int getMessageExpirationTime() {
104 return this.group
!= null && this.group
.hasDisappearingMessagesTimer()
105 ?
this.group
.getDisappearingMessagesTimer().getDuration()