X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/5cccf521032954d7ad8e3f70e3cbef2ce1293e85..b1e56faab2b2417af4f4a7f1033ffd752a9d16e4:/src/main/java/org/asamk/signal/commands/UnblockCommand.java diff --git a/src/main/java/org/asamk/signal/commands/UnblockCommand.java b/src/main/java/org/asamk/signal/commands/UnblockCommand.java index af49236c..4cfe4647 100644 --- a/src/main/java/org/asamk/signal/commands/UnblockCommand.java +++ b/src/main/java/org/asamk/signal/commands/UnblockCommand.java @@ -37,30 +37,28 @@ public class UnblockCommand implements JsonRpcLocalCommand { public void handleCommand( final Namespace ns, final Manager m, final OutputWriter outputWriter ) throws CommandException { - for (var contactNumber : CommandUtil.getSingleRecipientIdentifiers(ns.getList("recipient"), - m.getSelfNumber())) { - try { - m.setContactBlocked(contactNumber, false); - } catch (NotMasterDeviceException e) { - throw new UserErrorException("This command doesn't work on linked devices."); - } catch (IOException e) { - throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e); - } catch (UnregisteredRecipientException e) { - throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered."); - } + final var contacts = ns.getList("recipient"); + final var recipients = CommandUtil.getSingleRecipientIdentifiers(contacts, m.getSelfNumber()); + try { + m.setContactsBlocked(recipients, false); + } catch (NotMasterDeviceException e) { + throw new UserErrorException("This command doesn't work on linked devices."); + } catch (IOException e) { + throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e); + } catch (UnregisteredRecipientException e) { + throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered."); } final var groupIdStrings = ns.getList("group-id"); - for (var groupId : CommandUtil.getGroupIds(groupIdStrings)) { - try { - m.setGroupBlocked(groupId, false); - } catch (NotMasterDeviceException e) { - throw new UserErrorException("This command doesn't work on linked devices."); - } catch (GroupNotFoundException e) { - logger.warn("Unknown group id: {}", groupId); - } catch (IOException e) { - throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e); - } + final var groupIds = CommandUtil.getGroupIds(groupIdStrings); + try { + m.setGroupsBlocked(groupIds, false); + } catch (NotMasterDeviceException e) { + throw new UserErrorException("This command doesn't work on linked devices."); + } catch (GroupNotFoundException e) { + logger.warn("Unknown group id: {}", e.getMessage()); + } catch (IOException e) { + throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e); } } }