]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/VerifyCommand.java
Add MultiAccountManager
[signal-cli] / src / main / java / org / asamk / signal / commands / VerifyCommand.java
index c26c1d3a0701a949b865f1407ff7b2fcadd31b4d..155cdb09229f730206c0a40e83c27162374bac4b 100644 (file)
@@ -5,19 +5,23 @@ import net.sourceforge.argparse4j.inf.Subparser;
 
 import org.asamk.signal.commands.exceptions.CommandException;
 import org.asamk.signal.commands.exceptions.IOErrorException;
-import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
 import org.asamk.signal.commands.exceptions.UserErrorException;
 import org.asamk.signal.manager.RegistrationManager;
-import org.whispersystems.signalservice.api.KeyBackupServicePinException;
-import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException;
-import org.whispersystems.signalservice.internal.push.LockedException;
+import org.asamk.signal.manager.api.IncorrectPinException;
+import org.asamk.signal.manager.api.PinLockedException;
 
 import java.io.IOException;
 
 public class VerifyCommand implements RegistrationCommand {
 
+    @Override
+    public String getName() {
+        return "verify";
+    }
+
     @Override
     public void attachToSubparser(final Subparser subparser) {
+        subparser.help("Verify the number using the code received via SMS or voice.");
         subparser.addArgument("verificationCode").help("The verification code you received via sms or voice call.");
         subparser.addArgument("-p", "--pin").help("The registration lock PIN, that was set by the user (Optional)");
     }
@@ -29,17 +33,15 @@ public class VerifyCommand implements RegistrationCommand {
 
         try {
             m.verifyAccount(verificationCode, pin);
-        } catch (LockedException e) {
+        } catch (PinLockedException e) {
             throw new UserErrorException(
                     "Verification failed! This number is locked with a pin. Hours remaining until reset: "
                             + (e.getTimeRemaining() / 1000 / 60 / 60)
                             + "\nUse '--pin PIN_CODE' to specify the registration lock PIN");
-        } catch (KeyBackupServicePinException e) {
+        } catch (IncorrectPinException e) {
             throw new UserErrorException("Verification failed! Invalid pin, tries remaining: " + e.getTriesRemaining());
-        } catch (KeyBackupSystemNoDataException e) {
-            throw new UnexpectedErrorException("Verification failed! No KBS data.");
         } catch (IOException e) {
-            throw new IOErrorException("Verify error: " + e.getMessage());
+            throw new IOErrorException("Verify error: " + e.getMessage(), e);
         }
     }
 }