]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/BlockCommand.java
Add MultiAccountManager
[signal-cli] / src / main / java / org / asamk / signal / commands / BlockCommand.java
index 77a622b1b8fcdc4f4d1034cdbb15c44ea163d3d8..1ec1036cd828defa7bc508c2c5aa38aedad98239 100644 (file)
@@ -37,13 +37,13 @@ public class BlockCommand implements JsonRpcLocalCommand {
             final Namespace ns, final Manager m, final OutputWriter outputWriter
     ) throws CommandException {
         final var contacts = ns.<String>getList("recipient");
-        for (var contact : CommandUtil.getSingleRecipientIdentifiers(contacts, m.getUsername())) {
+        for (var contact : CommandUtil.getSingleRecipientIdentifiers(contacts, m.getSelfNumber())) {
             try {
                 m.setContactBlocked(contact, true);
             } catch (NotMasterDeviceException e) {
                 throw new UserErrorException("This command doesn't work on linked devices.");
             } catch (IOException e) {
-                throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage());
+                throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage(), e);
             }
         }
 
@@ -52,10 +52,12 @@ public class BlockCommand implements JsonRpcLocalCommand {
             for (var groupId : CommandUtil.getGroupIds(groupIdStrings)) {
                 try {
                     m.setGroupBlocked(groupId, true);
+                } catch (NotMasterDeviceException e) {
+                    throw new UserErrorException("This command doesn't work on linked devices.");
                 } catch (GroupNotFoundException e) {
                     logger.warn("Group not found {}: {}", groupId.toBase64(), e.getMessage());
                 } catch (IOException e) {
-                    throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage());
+                    throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage(), e);
                 }
             }
         }