]> nmode's Git Repositories - signal-cli/commitdiff
Mark group as active when the user hasn't left it
authorAsamK <asamk@gmx.de>
Sun, 22 Mar 2020 17:20:52 +0000 (18:20 +0100)
committerAsamK <asamk@gmx.de>
Sun, 22 Mar 2020 17:27:29 +0000 (18:27 +0100)
Fixes #269

src/main/java/org/asamk/signal/commands/ListGroupsCommand.java
src/main/java/org/asamk/signal/manager/Manager.java
src/main/java/org/asamk/signal/storage/groups/GroupInfo.java

index 9758b0e34b9fa555dff7415537294e84176af0dc..565bacba3cf305aefd9071f8dfec582e06d131b6 100644 (file)
@@ -12,13 +12,13 @@ import java.util.List;
 
 public class ListGroupsCommand implements LocalCommand {
 
-    private static void printGroup(GroupInfo group, boolean detailed) {
+    private static void printGroup(GroupInfo group, boolean detailed, String username) {
         if (detailed) {
             System.out.println(String.format("Id: %s Name: %s  Active: %s Blocked: %b Members: %s",
-                    Base64.encodeBytes(group.groupId), group.name, group.active, group.blocked, group.members));
+                    Base64.encodeBytes(group.groupId), group.name, group.members.contains(username), group.blocked, group.members));
         } else {
             System.out.println(String.format("Id: %s Name: %s  Active: %s Blocked: %b",
-                    Base64.encodeBytes(group.groupId), group.name, group.active, group.blocked));
+                    Base64.encodeBytes(group.groupId), group.name, group.members.contains(username), group.blocked));
         }
     }
 
@@ -40,7 +40,7 @@ public class ListGroupsCommand implements LocalCommand {
         boolean detailed = ns.getBoolean("detailed");
 
         for (GroupInfo group : groups) {
-            printGroup(group, detailed);
+            printGroup(group, detailed, m.getUsername());
         }
         return 0;
     }
index ded15980ef2bb7f246bcf12d52cd2b37e210dfa2..f5bbe146fddacfbaf65b00514176660bbd840a1f 100644 (file)
@@ -1450,7 +1450,9 @@ public class Manager implements Signal {
                                     syncGroup.name = g.getName().get();
                                 }
                                 syncGroup.addMembers(g.getMembers());
-                                syncGroup.active = g.isActive();
+                                if (!g.isActive()) {
+                                    syncGroup.members.remove(username);
+                                }
                                 syncGroup.blocked = g.isBlocked();
                                 if (g.getColor().isPresent()) {
                                     syncGroup.color = g.getColor().get();
@@ -1666,7 +1668,7 @@ public class Manager implements Signal {
                     ThreadInfo info = account.getThreadStore().getThread(Base64.encodeBytes(record.groupId));
                     out.write(new DeviceGroup(record.groupId, Optional.fromNullable(record.name),
                             new ArrayList<>(record.getMembers()), createGroupAvatarAttachment(record.groupId),
-                            record.active, Optional.fromNullable(info != null ? info.messageExpirationTime : null),
+                            record.members.contains(username), Optional.fromNullable(info != null ? info.messageExpirationTime : null),
                             Optional.fromNullable(record.color), record.blocked, Optional.fromNullable(record.inboxPosition), record.archived));
                 }
             }
index 0387efac54c3fb4a840eb9ee654cfc43826058b9..cb53d3af3a44ed275da71b5901417e6016138f5f 100644 (file)
@@ -20,8 +20,6 @@ public class GroupInfo {
     @JsonProperty
     public Set<String> members = new HashSet<>();
     @JsonProperty
-    public boolean active;
-    @JsonProperty
     public String color;
     @JsonProperty(defaultValue = "false")
     public boolean blocked;
@@ -32,17 +30,23 @@ public class GroupInfo {
 
     private long avatarId;
 
+    @JsonProperty
+    @JsonIgnore
+    private boolean active;
+
     public GroupInfo(byte[] groupId) {
         this.groupId = groupId;
     }
 
-    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) {
+    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