]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/TrustCommand.java
Handle rate limit exception correctly when querying usernames
[signal-cli] / src / main / java / org / asamk / signal / commands / TrustCommand.java
index 7d1dd6321c2cc76e4275ab6f64688a912f4777c7..7f18507adf32538ed3df1a3f10f86a2f7e01bdb1 100644 (file)
@@ -33,20 +33,22 @@ public class TrustCommand implements JsonRpcLocalCommand {
 
     @Override
     public void handleCommand(
-            final Namespace ns, final Manager m, final OutputWriter outputWriter
+            final Namespace ns,
+            final Manager m,
+            final OutputWriter outputWriter
     ) throws CommandException {
-        var recipentString = ns.getString("recipient");
-        var recipient = CommandUtil.getSingleRecipientIdentifier(recipentString, m.getSelfNumber());
+        var recipientString = ns.getString("recipient");
+        var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
         if (Boolean.TRUE.equals(ns.getBoolean("trust-all-known-keys"))) {
-            boolean res;
             try {
-                res = m.trustIdentityAllKeys(recipient);
+                final var res = m.trustIdentityAllKeys(recipient);
+                if (!res) {
+                    throw new UserErrorException(
+                            "Failed to set the trust for this number, make sure the number is correct.");
+                }
             } catch (UnregisteredRecipientException e) {
                 throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
             }
-            if (!res) {
-                throw new UserErrorException("Failed to set the trust for this number, make sure the number is correct.");
-            }
         } else {
             var safetyNumber = ns.getString("verified-safety-number");
             if (safetyNumber == null) {