mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-08-29 06:06:22 +00:00
Force a group refresh when using listGroups command with groupId
Fixes #1802
This commit is contained in:
parent
371dc06842
commit
a22af8303a
@ -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
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 -> {
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user