]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/storage/groups/GroupInfoV2.java
1 package org
.asamk
.signal
.storage
.groups
;
3 import org
.asamk
.signal
.manager
.groups
.GroupIdV2
;
4 import org
.asamk
.signal
.manager
.groups
.GroupInviteLinkUrl
;
5 import org
.signal
.storageservice
.protos
.groups
.AccessControl
;
6 import org
.signal
.storageservice
.protos
.groups
.local
.DecryptedGroup
;
7 import org
.signal
.zkgroup
.groups
.GroupMasterKey
;
8 import org
.whispersystems
.signalservice
.api
.push
.SignalServiceAddress
;
9 import org
.whispersystems
.signalservice
.api
.util
.UuidUtil
;
11 import java
.util
.Collections
;
13 import java
.util
.stream
.Collectors
;
15 public class GroupInfoV2
extends GroupInfo
{
17 private final GroupIdV2 groupId
;
18 private final GroupMasterKey masterKey
;
20 private boolean blocked
;
21 private DecryptedGroup group
; // stored as a file with hexadecimal groupId as name
23 public GroupInfoV2(final GroupIdV2 groupId
, final GroupMasterKey masterKey
) {
24 this.groupId
= groupId
;
25 this.masterKey
= masterKey
;
29 public GroupIdV2
getGroupId() {
33 public GroupMasterKey
getMasterKey() {
37 public void setGroup(final DecryptedGroup group
) {
41 public DecryptedGroup
getGroup() {
46 public String
getTitle() {
47 if (this.group
== null) {
50 return this.group
.getTitle();
54 public GroupInviteLinkUrl
getGroupInviteLink() {
55 if (this.group
== null || this.group
.getInviteLinkPassword() == null || (
56 this.group
.getAccessControl().getAddFromInviteLink() != AccessControl
.AccessRequired
.ANY
57 && this.group
.getAccessControl().getAddFromInviteLink()
58 != AccessControl
.AccessRequired
.ADMINISTRATOR
63 return GroupInviteLinkUrl
.forGroup(masterKey
, group
);
67 public Set
<SignalServiceAddress
> getMembers() {
68 if (this.group
== null) {
69 return Collections
.emptySet();
71 return group
.getMembersList()
73 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
74 .collect(Collectors
.toSet());
78 public Set
<SignalServiceAddress
> getPendingMembers() {
79 if (this.group
== null) {
80 return Collections
.emptySet();
82 return group
.getPendingMembersList()
84 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
85 .collect(Collectors
.toSet());
89 public Set
<SignalServiceAddress
> getRequestingMembers() {
90 if (this.group
== null) {
91 return Collections
.emptySet();
93 return group
.getRequestingMembersList()
95 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
96 .collect(Collectors
.toSet());
100 public boolean isBlocked() {
105 public void setBlocked(final boolean blocked
) {
106 this.blocked
= blocked
;
110 public int getMessageExpirationTime() {
111 return this.group
!= null && this.group
.hasDisappearingMessagesTimer()
112 ?
this.group
.getDisappearingMessagesTimer().getDuration()