Approve join requests instead of just adding the member

This commit is contained in:
AsamK 2022-10-07 20:05:49 +02:00
parent 01e1115806
commit 1424a2980f
2 changed files with 25 additions and 0 deletions

View file

@ -593,8 +593,15 @@ public class GroupHelper {
}
if (members != null) {
final var requestingMembers = new HashSet<>(members);
requestingMembers.retainAll(group.getRequestingMembers());
if (requestingMembers.size() > 0) {
var groupGroupChangePair = groupV2Helper.approveJoinRequestMembers(group, requestingMembers);
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
}
final var newMembers = new HashSet<>(members);
newMembers.removeAll(group.getMembers());
newMembers.removeAll(group.getRequestingMembers());
if (newMembers.size() > 0) {
var groupGroupChangePair = groupV2Helper.addMembers(group, newMembers);
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());

View file

@ -287,6 +287,17 @@ class GroupV2Helper {
return ejectMembers(groupInfoV2, memberUuids);
}
Pair<DecryptedGroup, GroupChange> approveJoinRequestMembers(
GroupInfoV2 groupInfoV2, Set<RecipientId> members
) throws IOException {
final var memberUuids = members.stream()
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
.map(SignalServiceAddress::getServiceId)
.map(ServiceId::uuid)
.collect(Collectors.toSet());
return approveJoinRequest(groupInfoV2, memberUuids);
}
Pair<DecryptedGroup, GroupChange> refuseJoinRequestMembers(
GroupInfoV2 groupInfoV2, Set<RecipientId> members
) throws IOException {
@ -524,6 +535,13 @@ class GroupV2Helper {
return commitChange(groupInfoV2, groupOperations.createRemoveInvitationChange(uuidCipherTexts));
}
private Pair<DecryptedGroup, GroupChange> approveJoinRequest(
GroupInfoV2 groupInfoV2, Set<UUID> uuids
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
return commitChange(groupInfoV2, groupOperations.createApproveGroupJoinRequest(uuids));
}
private Pair<DecryptedGroup, GroupChange> refuseJoinRequest(
GroupInfoV2 groupInfoV2, Set<UUID> uuids
) throws IOException {