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));
}
}
boolean detailed = ns.getBoolean("detailed");
for (GroupInfo group : groups) {
- printGroup(group, detailed);
+ printGroup(group, detailed, m.getUsername());
}
return 0;
}
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();
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));
}
}
@JsonProperty
public Set<String> members = new HashSet<>();
@JsonProperty
- public boolean active;
- @JsonProperty
public String color;
@JsonProperty(defaultValue = "false")
public boolean blocked;
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