X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/8f781c019f5f451c9d6323659bb248be335ad0e5..2ab42ca5471e8fc1e1a31cde954e19564178f114:/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java diff --git a/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java b/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java index 35f530b0..e69bf059 100644 --- a/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java +++ b/src/main/java/org/asamk/signal/dbus/DbusSignalControlImpl.java @@ -8,11 +8,11 @@ import org.asamk.signal.manager.Manager; import org.asamk.signal.manager.ProvisioningManager; import org.asamk.signal.manager.RegistrationManager; import org.asamk.signal.manager.UserAlreadyExists; +import org.asamk.signal.manager.api.CaptchaRequiredException; +import org.asamk.signal.manager.api.IncorrectPinException; +import org.asamk.signal.manager.api.Pair; +import org.asamk.signal.manager.api.PinLockedException; import org.freedesktop.dbus.DBusPath; -import org.whispersystems.libsignal.util.Pair; -import org.whispersystems.signalservice.api.KeyBackupServicePinException; -import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException; -import org.whispersystems.signalservice.api.push.exceptions.CaptchaRequiredException; import java.io.IOException; import java.net.URI; @@ -99,6 +99,10 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl { public void registerWithCaptcha( final String number, final boolean voiceVerification, final String captcha ) throws Error.Failure, Error.InvalidNumber { + if (!Manager.isValidNumber(number, null)) { + throw new SignalControl.Error.InvalidNumber( + "Invalid username (phone number), make sure you include the country code."); + } try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) { registrationManager.register(voiceVerification, captcha); } catch (CaptchaRequiredException e) { @@ -121,7 +125,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl { try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) { final Manager manager = registrationManager.verifyAccount(verificationCode, pin); addManager(manager); - } catch (IOException | KeyBackupSystemNoDataException | KeyBackupServicePinException e) { + } catch (IOException | PinLockedException | IncorrectPinException e) { throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage()); } } @@ -155,7 +159,7 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl { synchronized (receiveThreads) { return receiveThreads.stream() .map(Pair::first) - .map(Manager::getUsername) + .map(Manager::getSelfNumber) .map(u -> new DBusPath(DbusConfig.getObjectPath(u))) .collect(Collectors.toList()); }