Implement add/remove admin privileges

This commit is contained in:
AsamK 2021-05-15 11:08:01 +02:00
parent b972522d74
commit 3de30e166f
7 changed files with 104 additions and 15 deletions

View file

@ -38,7 +38,7 @@ public class ListGroupsCommand implements LocalCommand {
final var groupInviteLink = group.getGroupInviteLink();
writer.println(
"Id: {} Name: {} Description: {} Active: {} Blocked: {} Members: {} Pending members: {} Requesting members: {} Link: {}",
"Id: {} Name: {} Description: {} Active: {} Blocked: {} Members: {} Pending members: {} Requesting members: {} Admins: {} Link: {}",
group.getGroupId().toBase64(),
group.getTitle(),
group.getDescription(),
@ -47,6 +47,7 @@ public class ListGroupsCommand implements LocalCommand {
resolveMembers(m, group.getMembers()),
resolveMembers(m, group.getPendingMembers()),
resolveMembers(m, group.getRequestingMembers()),
resolveMembers(m, group.getAdminMembers()),
groupInviteLink == null ? '-' : groupInviteLink.getUrl());
} else {
writer.println("Id: {} Name: {} Active: {} Blocked: {}",
@ -88,6 +89,7 @@ public class ListGroupsCommand implements LocalCommand {
resolveMembers(m, group.getMembers()),
resolveMembers(m, group.getPendingMembers()),
resolveMembers(m, group.getRequestingMembers()),
resolveMembers(m, group.getAdminMembers()),
groupInviteLink == null ? null : groupInviteLink.getUrl()));
}
@ -112,6 +114,7 @@ public class ListGroupsCommand implements LocalCommand {
public Set<String> members;
public Set<String> pendingMembers;
public Set<String> requestingMembers;
public Set<String> admins;
public String groupInviteLink;
public JsonGroup(
@ -123,6 +126,7 @@ public class ListGroupsCommand implements LocalCommand {
Set<String> members,
Set<String> pendingMembers,
Set<String> requestingMembers,
Set<String> admins,
String groupInviteLink
) {
this.id = id;
@ -134,6 +138,7 @@ public class ListGroupsCommand implements LocalCommand {
this.members = members;
this.pendingMembers = pendingMembers;
this.requestingMembers = requestingMembers;
this.admins = admins;
this.groupInviteLink = groupInviteLink;
}
}

View file

@ -41,6 +41,11 @@ public class UpdateGroupCommand implements DbusCommand, LocalCommand {
subparser.addArgument("-r", "--remove-member")
.nargs("*")
.help("Specify one or more members to remove from the group");
subparser.addArgument("--admin").nargs("*").help("Specify one or more members to make a group admin");
subparser.addArgument("--remove-admin")
.nargs("*")
.help("Specify one or more members to remove group admin privileges");
}
@Override
@ -64,6 +69,10 @@ public class UpdateGroupCommand implements DbusCommand, LocalCommand {
List<String> groupRemoveMembers = ns.getList("remove-member");
List<String> groupAdmins = ns.getList("admin");
List<String> groupRemoveAdmins = ns.getList("remove-admin");
var groupAvatar = ns.getString("avatar");
try {
@ -80,6 +89,8 @@ public class UpdateGroupCommand implements DbusCommand, LocalCommand {
groupDescription,
groupMembers,
groupRemoveMembers,
groupAdmins,
groupRemoveAdmins,
groupAvatar == null ? null : new File(groupAvatar));
ErrorUtils.handleTimestampAndSendMessageResults(writer, results.first(), results.second());
}

View file

@ -345,6 +345,8 @@ public class DbusSignalImpl implements Signal {
null,
members,
null,
null,
null,
avatar == null ? null : new File(avatar));
checkSendMessageResults(results.first(), results.second());
return groupId;