]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/storage/groups/GroupInfo.java
Show pending and requesting members of v2 groups
[signal-cli] / src / main / java / org / asamk / signal / storage / groups / GroupInfo.java
index cb53d3af3a44ed275da71b5901417e6016138f5f..d24a2694251ef85215559c24d544f85ab7d4ff13 100644 (file)
@@ -5,67 +5,61 @@ import com.fasterxml.jackson.annotation.JsonProperty;
 
 import org.whispersystems.signalservice.api.push.SignalServiceAddress;
 
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
-public class GroupInfo {
+public abstract class GroupInfo {
 
     @JsonProperty
     public final byte[] groupId;
 
-    @JsonProperty
-    public String name;
-
-    @JsonProperty
-    public Set<String> members = new HashSet<>();
-    @JsonProperty
-    public String color;
-    @JsonProperty(defaultValue = "false")
-    public boolean blocked;
-    @JsonProperty
-    public Integer inboxPosition;
-    @JsonProperty(defaultValue = "false")
-    public boolean archived;
+    public GroupInfo(byte[] groupId) {
+        this.groupId = groupId;
+    }
 
-    private long avatarId;
+    @JsonIgnore
+    public abstract String getTitle();
 
-    @JsonProperty
     @JsonIgnore
-    private boolean active;
+    public abstract Set<SignalServiceAddress> getMembers();
 
-    public GroupInfo(byte[] groupId) {
-        this.groupId = groupId;
+    @JsonIgnore
+    public Set<SignalServiceAddress> getPendingMembers() {
+        return Set.of();
     }
 
-    public GroupInfo(@JsonProperty("groupId") byte[] groupId, @JsonProperty("name") String name, @JsonProperty("members") Collection<String> members, @JsonProperty("avatarId") long avatarId, @JsonProperty("color") String color, @JsonProperty("blocked") boolean blocked, @JsonProperty("inboxPosition") Integer inboxPosition, @JsonProperty("archived") boolean archived) {
-        this.groupId = groupId;
-        this.name = name;
-        this.members.addAll(members);
-        this.avatarId = avatarId;
-        this.color = color;
-        this.blocked = blocked;
-        this.inboxPosition = inboxPosition;
-        this.archived = archived;
+    @JsonIgnore
+    public Set<SignalServiceAddress> getRequestingMembers() {
+        return Set.of();
     }
 
     @JsonIgnore
-    public long getAvatarId() {
-        return avatarId;
-    }
+    public abstract boolean isBlocked();
 
     @JsonIgnore
-    public Set<SignalServiceAddress> getMembers() {
-        Set<SignalServiceAddress> addresses = new HashSet<>(members.size());
-        for (String member : members) {
-            addresses.add(new SignalServiceAddress(null, member));
+    public abstract void setBlocked(boolean blocked);
+
+    @JsonIgnore
+    public abstract int getMessageExpirationTime();
+
+    @JsonIgnore
+    public Set<SignalServiceAddress> getMembersWithout(SignalServiceAddress address) {
+        Set<SignalServiceAddress> members = new HashSet<>();
+        for (SignalServiceAddress member : getMembers()) {
+            if (!member.matches(address)) {
+                members.add(member);
+            }
         }
-        return addresses;
+        return members;
     }
 
-    public void addMembers(Collection<SignalServiceAddress> members) {
-        for (SignalServiceAddress member : members) {
-            this.members.add(member.getNumber().get());
+    @JsonIgnore
+    public boolean isMember(SignalServiceAddress address) {
+        for (SignalServiceAddress member : getMembers()) {
+            if (member.matches(address)) {
+                return true;
+            }
         }
+        return false;
     }
 }