mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Add ListGroups command
Option: -d/--detailed to display group members
This commit is contained in:
parent
453f31891c
commit
b0d7daeca2
2 changed files with 36 additions and 0 deletions
|
@ -491,6 +491,22 @@ public class Main {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "listGroups":
|
||||||
|
if (dBusConn != null) {
|
||||||
|
System.err.println("listGroups is not yet implemented via dbus");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!m.isRegistered()) {
|
||||||
|
System.err.println("User is not registered.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GroupInfo> groups = m.getGroups();
|
||||||
|
|
||||||
|
for (GroupInfo group : groups) {
|
||||||
|
printGroup(group, ns.getBoolean("detailed"));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "listIdentities":
|
case "listIdentities":
|
||||||
if (dBusConn != null) {
|
if (dBusConn != null) {
|
||||||
|
@ -622,6 +638,17 @@ public class Main {
|
||||||
System.out.println(String.format("%s: %s Added: %s Fingerprint: %s Safety Number: %s", theirUsername,
|
System.out.println(String.format("%s: %s Added: %s Fingerprint: %s Safety Number: %s", theirUsername,
|
||||||
theirId.trustLevel, theirId.added, Hex.toStringCondensed(theirId.getFingerprint()), digits));
|
theirId.trustLevel, theirId.added, Hex.toStringCondensed(theirId.getFingerprint()), digits));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void printGroup(GroupInfo group, boolean detailed) {
|
||||||
|
System.out.println(String.format("Group id: %s\n Group name: %s \n active: %s",
|
||||||
|
Base64.encodeBytes(group.groupId), group.name, group.active));
|
||||||
|
if (detailed) {
|
||||||
|
System.out.println(" Members:");
|
||||||
|
for (String member : group.members) {
|
||||||
|
System.out.println(" " + member);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static String formatSafetyNumber(String digits) {
|
private static String formatSafetyNumber(String digits) {
|
||||||
final int partCount = 12;
|
final int partCount = 12;
|
||||||
|
@ -751,6 +778,11 @@ public class Main {
|
||||||
parserUpdateGroup.addArgument("-m", "--member")
|
parserUpdateGroup.addArgument("-m", "--member")
|
||||||
.nargs("*")
|
.nargs("*")
|
||||||
.help("Specify one or more members to add to the group");
|
.help("Specify one or more members to add to the group");
|
||||||
|
|
||||||
|
Subparser parserListGroups = subparsers.addParser("listGroups");
|
||||||
|
parserListGroups.addArgument("-d", "--detailed").action(Arguments.storeTrue())
|
||||||
|
.help("List members of each group");
|
||||||
|
parserListGroups.help("List group name and ids");
|
||||||
|
|
||||||
Subparser parserListIdentities = subparsers.addParser("listIdentities");
|
Subparser parserListIdentities = subparsers.addParser("listIdentities");
|
||||||
parserListIdentities.addArgument("-n", "--number")
|
parserListIdentities.addArgument("-n", "--number")
|
||||||
|
|
|
@ -580,6 +580,10 @@ class Manager implements Signal {
|
||||||
}
|
}
|
||||||
throw new NotAGroupMemberException(groupId, g.name);
|
throw new NotAGroupMemberException(groupId, g.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<GroupInfo> getGroups() {
|
||||||
|
return groupStore.getGroups();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendGroupMessage(String messageText, List<String> attachments,
|
public void sendGroupMessage(String messageText, List<String> attachments,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue