mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Approve join requests instead of just adding the member
This commit is contained in:
parent
01e1115806
commit
1424a2980f
2 changed files with 25 additions and 0 deletions
|
@ -593,8 +593,15 @@ public class GroupHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (members != null) {
|
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);
|
final var newMembers = new HashSet<>(members);
|
||||||
newMembers.removeAll(group.getMembers());
|
newMembers.removeAll(group.getMembers());
|
||||||
|
newMembers.removeAll(group.getRequestingMembers());
|
||||||
if (newMembers.size() > 0) {
|
if (newMembers.size() > 0) {
|
||||||
var groupGroupChangePair = groupV2Helper.addMembers(group, newMembers);
|
var groupGroupChangePair = groupV2Helper.addMembers(group, newMembers);
|
||||||
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
result = sendUpdateGroupV2Message(group, groupGroupChangePair.first(), groupGroupChangePair.second());
|
||||||
|
|
|
@ -287,6 +287,17 @@ class GroupV2Helper {
|
||||||
return ejectMembers(groupInfoV2, memberUuids);
|
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(
|
Pair<DecryptedGroup, GroupChange> refuseJoinRequestMembers(
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> members
|
GroupInfoV2 groupInfoV2, Set<RecipientId> members
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
|
@ -524,6 +535,13 @@ class GroupV2Helper {
|
||||||
return commitChange(groupInfoV2, groupOperations.createRemoveInvitationChange(uuidCipherTexts));
|
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(
|
private Pair<DecryptedGroup, GroupChange> refuseJoinRequest(
|
||||||
GroupInfoV2 groupInfoV2, Set<UUID> uuids
|
GroupInfoV2 groupInfoV2, Set<UUID> uuids
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue