]>
nmode's Git Repositories - signal-cli/blob - src/main/java/org/asamk/signal/manager/storage/groups/GroupInfoV2.java
2092c03aa648a82de6157c4ab2d802e5092f3d92
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
.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
;
12 import java
.util
.stream
.Collectors
;
14 public class GroupInfoV2
extends GroupInfo
{
16 private final GroupIdV2 groupId
;
17 private final GroupMasterKey masterKey
;
19 private boolean blocked
;
20 private DecryptedGroup group
; // stored as a file with hexadecimal groupId as name
22 public GroupInfoV2(final GroupIdV2 groupId
, final GroupMasterKey masterKey
) {
23 this.groupId
= groupId
;
24 this.masterKey
= masterKey
;
28 public GroupIdV2
getGroupId() {
32 public GroupMasterKey
getMasterKey() {
36 public void setGroup(final DecryptedGroup group
) {
40 public DecryptedGroup
getGroup() {
45 public String
getTitle() {
46 if (this.group
== null) {
49 return this.group
.getTitle();
53 public GroupInviteLinkUrl
getGroupInviteLink() {
54 if (this.group
== null || this.group
.getInviteLinkPassword() == null || (
55 this.group
.getAccessControl().getAddFromInviteLink() != AccessControl
.AccessRequired
.ANY
56 && this.group
.getAccessControl().getAddFromInviteLink()
57 != AccessControl
.AccessRequired
.ADMINISTRATOR
62 return GroupInviteLinkUrl
.forGroup(masterKey
, group
);
66 public Set
<SignalServiceAddress
> getMembers() {
67 if (this.group
== null) {
70 return group
.getMembersList()
72 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
73 .collect(Collectors
.toSet());
77 public Set
<SignalServiceAddress
> getPendingMembers() {
78 if (this.group
== null) {
81 return group
.getPendingMembersList()
83 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
84 .collect(Collectors
.toSet());
88 public Set
<SignalServiceAddress
> getRequestingMembers() {
89 if (this.group
== null) {
92 return group
.getRequestingMembersList()
94 .map(m
-> new SignalServiceAddress(UuidUtil
.parseOrThrow(m
.getUuid().toByteArray()), null))
95 .collect(Collectors
.toSet());
99 public boolean isBlocked() {
104 public void setBlocked(final boolean blocked
) {
105 this.blocked
= blocked
;
109 public int getMessageExpirationTime() {
110 return this.group
!= null && this.group
.hasDisappearingMessagesTimer()
111 ?
this.group
.getDisappearingMessagesTimer().getDuration()