X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/b972522d749d6f82898c7919f2f5b36a7dbc2f9b..3de30e166f4eb6be0cd10548ed2c6cce2fe2282e:/lib/src/main/java/org/asamk/signal/manager/Manager.java diff --git a/lib/src/main/java/org/asamk/signal/manager/Manager.java b/lib/src/main/java/org/asamk/signal/manager/Manager.java index cd0ce561..b003279a 100644 --- a/lib/src/main/java/org/asamk/signal/manager/Manager.java +++ b/lib/src/main/java/org/asamk/signal/manager/Manager.java @@ -831,6 +831,8 @@ public class Manager implements Closeable { String description, List members, List removeMembers, + List admins, + List removeAdmins, File avatarFile ) throws IOException, GroupNotFoundException, AttachmentInvalidException, InvalidNumberException, NotAGroupMemberException { return updateGroup(groupId, @@ -838,21 +840,32 @@ public class Manager implements Closeable { description, members == null ? null : getSignalServiceAddresses(members), removeMembers == null ? null : getSignalServiceAddresses(removeMembers), + admins == null ? null : getSignalServiceAddresses(admins), + removeAdmins == null ? null : getSignalServiceAddresses(removeAdmins), avatarFile); } private Pair> updateGroup( - GroupId groupId, - String name, - String description, - Set members, + final GroupId groupId, + final String name, + final String description, + final Set members, final Set removeMembers, - File avatarFile + final Set admins, + final Set removeAdmins, + final File avatarFile ) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException { var group = getGroupForUpdating(groupId); if (group instanceof GroupInfoV2) { - return updateGroupV2((GroupInfoV2) group, name, description, members, removeMembers, avatarFile); + return updateGroupV2((GroupInfoV2) group, + name, + description, + members, + removeMembers, + admins, + removeAdmins, + avatarFile); } return updateGroupV1((GroupInfoV1) group, name, members, avatarFile); @@ -913,6 +926,8 @@ public class Manager implements Closeable { final String description, final Set members, final Set removeMembers, + final Set admins, + final Set removeAdmins, final File avatarFile ) throws IOException { Pair> result = null; @@ -947,6 +962,33 @@ public class Manager implements Closeable { } } + if (admins != null) { + final var newAdmins = new HashSet<>(admins); + newAdmins.retainAll(group.getMembers()); + newAdmins.removeAll(group.getAdminMembers()); + if (newAdmins.size() > 0) { + for (var admin : newAdmins) { + var groupGroupChangePair = groupV2Helper.setMemberAdmin(group, admin, true); + result = sendUpdateGroupV2Message(group, + groupGroupChangePair.first(), + groupGroupChangePair.second()); + } + } + } + + if (removeAdmins != null) { + final var existingRemoveAdmins = new HashSet<>(removeAdmins); + existingRemoveAdmins.retainAll(group.getAdminMembers()); + if (existingRemoveAdmins.size() > 0) { + for (var admin : existingRemoveAdmins) { + var groupGroupChangePair = groupV2Helper.setMemberAdmin(group, admin, false); + result = sendUpdateGroupV2Message(group, + groupGroupChangePair.first(), + groupGroupChangePair.second()); + } + } + } + if (result == null || name != null || description != null || avatarFile != null) { var groupGroupChangePair = groupV2Helper.updateGroup(group, name, description, avatarFile); if (avatarFile != null) {