mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
parent
67f6378f7f
commit
bb06ae9d9a
3 changed files with 15 additions and 9 deletions
|
@ -12,13 +12,13 @@ import java.util.List;
|
||||||
|
|
||||||
public class ListGroupsCommand implements LocalCommand {
|
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) {
|
if (detailed) {
|
||||||
System.out.println(String.format("Id: %s Name: %s Active: %s Blocked: %b Members: %s",
|
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 {
|
} else {
|
||||||
System.out.println(String.format("Id: %s Name: %s Active: %s Blocked: %b",
|
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");
|
boolean detailed = ns.getBoolean("detailed");
|
||||||
|
|
||||||
for (GroupInfo group : groups) {
|
for (GroupInfo group : groups) {
|
||||||
printGroup(group, detailed);
|
printGroup(group, detailed, m.getUsername());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1450,7 +1450,9 @@ public class Manager implements Signal {
|
||||||
syncGroup.name = g.getName().get();
|
syncGroup.name = g.getName().get();
|
||||||
}
|
}
|
||||||
syncGroup.addMembers(g.getMembers());
|
syncGroup.addMembers(g.getMembers());
|
||||||
syncGroup.active = g.isActive();
|
if (!g.isActive()) {
|
||||||
|
syncGroup.members.remove(username);
|
||||||
|
}
|
||||||
syncGroup.blocked = g.isBlocked();
|
syncGroup.blocked = g.isBlocked();
|
||||||
if (g.getColor().isPresent()) {
|
if (g.getColor().isPresent()) {
|
||||||
syncGroup.color = g.getColor().get();
|
syncGroup.color = g.getColor().get();
|
||||||
|
@ -1666,7 +1668,7 @@ public class Manager implements Signal {
|
||||||
ThreadInfo info = account.getThreadStore().getThread(Base64.encodeBytes(record.groupId));
|
ThreadInfo info = account.getThreadStore().getThread(Base64.encodeBytes(record.groupId));
|
||||||
out.write(new DeviceGroup(record.groupId, Optional.fromNullable(record.name),
|
out.write(new DeviceGroup(record.groupId, Optional.fromNullable(record.name),
|
||||||
new ArrayList<>(record.getMembers()), createGroupAvatarAttachment(record.groupId),
|
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));
|
Optional.fromNullable(record.color), record.blocked, Optional.fromNullable(record.inboxPosition), record.archived));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@ public class GroupInfo {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
public Set<String> members = new HashSet<>();
|
public Set<String> members = new HashSet<>();
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
public boolean active;
|
|
||||||
@JsonProperty
|
|
||||||
public String color;
|
public String color;
|
||||||
@JsonProperty(defaultValue = "false")
|
@JsonProperty(defaultValue = "false")
|
||||||
public boolean blocked;
|
public boolean blocked;
|
||||||
|
@ -32,17 +30,23 @@ public class GroupInfo {
|
||||||
|
|
||||||
private long avatarId;
|
private long avatarId;
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
@JsonIgnore
|
||||||
|
private boolean active;
|
||||||
|
|
||||||
public GroupInfo(byte[] groupId) {
|
public GroupInfo(byte[] groupId) {
|
||||||
this.groupId = 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.groupId = groupId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.members.addAll(members);
|
this.members.addAll(members);
|
||||||
this.avatarId = avatarId;
|
this.avatarId = avatarId;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.blocked = blocked;
|
this.blocked = blocked;
|
||||||
|
this.inboxPosition = inboxPosition;
|
||||||
|
this.archived = archived;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue