- public int handleCommand(final Namespace ns, final Manager m) {
- for (var contact_number : ns.<String>getList("contact")) {
- try {
- m.setContactBlocked(contact_number, false);
- } catch (InvalidNumberException e) {
- System.err.println(e.getMessage());
- }
+ public void handleCommand(
+ final Namespace ns, final Manager m, final OutputWriter outputWriter
+ ) throws CommandException {
+ final var contacts = ns.<String>getList("recipient");
+ final var recipients = CommandUtil.getSingleRecipientIdentifiers(contacts, m.getSelfNumber());
+ try {
+ m.setContactsBlocked(recipients, false);
+ } catch (NotPrimaryDeviceException 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.");