Force a group refresh when using listGroups command with groupId

Fixes #1802
This commit is contained in:
AsamK 2025-09-14 18:24:07 +02:00
parent 371dc06842
commit a22af8303a
5 changed files with 28 additions and 5 deletions

View File

@ -162,6 +162,8 @@ public interface Manager extends Closeable {
List<Group> getGroups();
List<Group> getGroups(Collection<GroupId> groupIds);
SendGroupMessageResults quitGroup(
GroupId groupId,
Set<RecipientIdentifier.Single> groupAdmins

View File

@ -92,6 +92,16 @@ public class GroupHelper {
return groups;
}
public List<GroupInfo> getGroups(Collection<GroupId> groupIds) {
final var groups = account.getGroupStore()
.getGroups()
.stream()
.filter(g -> groupIds.contains(g.getGroupId()))
.toList();
groups.forEach(group -> fillOrUpdateGroup(group, true));
return groups;
}
public boolean isGroupBlocked(final GroupId groupId) {
var group = getGroup(groupId);
return group != null && group.isBlocked();

View File

@ -541,6 +541,11 @@ public class ManagerImpl implements Manager {
return context.getGroupHelper().getGroups().stream().map(this::toGroup).toList();
}
@Override
public List<Group> getGroups(Collection<GroupId> groupIds) {
return context.getGroupHelper().getGroups(groupIds).stream().map(this::toGroup).toList();
}
private Group toGroup(final GroupInfo groupInfo) {
if (groupInfo == null) {
return null;

View File

@ -81,13 +81,9 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
final Manager m,
final OutputWriter outputWriter
) throws CommandException {
var groups = m.getGroups();
final var groupIdStrings = ns.<String>getList("group-id");
final var groupIds = CommandUtil.getGroupIds(groupIdStrings);
if (!groupIds.isEmpty()) {
groups = groups.stream().filter(g -> groupIds.contains(g.groupId())).toList();
}
var groups = groupIds.isEmpty() ? m.getGroups() : m.getGroups(groupIds);
switch (outputWriter) {
case JsonWriter jsonWriter -> {

View File

@ -272,6 +272,16 @@ public class DbusManagerImpl implements Manager {
return groups.stream().map(Signal.StructGroup::getObjectPath).map(this::getGroup).toList();
}
@Override
public List<Group> getGroups(final Collection<GroupId> groupIds) {
final var groups = signal.listGroups();
return groups.stream()
.map(Signal.StructGroup::getObjectPath)
.map(this::getGroup)
.filter(g -> groupIds.contains(g.groupId()))
.toList();
}
@Override
public SendGroupMessageResults quitGroup(
final GroupId groupId,