mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Update libsignal-service-java
- Use session based number verification and registration
This commit is contained in:
parent
20b3563f21
commit
276ecef300
19 changed files with 359 additions and 158 deletions
|
@ -13,7 +13,9 @@ import org.asamk.signal.commands.exceptions.UserErrorException;
|
|||
import org.asamk.signal.manager.RegistrationManager;
|
||||
import org.asamk.signal.manager.api.CaptchaRequiredException;
|
||||
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.output.JsonWriter;
|
||||
import org.asamk.signal.util.DateUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -65,6 +67,12 @@ public class RegisterCommand implements RegistrationCommand, JsonRpcRegistration
|
|||
) throws UserErrorException, IOErrorException {
|
||||
try {
|
||||
m.register(voiceVerification, captcha);
|
||||
} catch (RateLimitException e) {
|
||||
String message = "Rate limit reached";
|
||||
if (e.getNextAttemptTimestamp() > 0) {
|
||||
message += "\nNext attempt may be tried at " + DateUtils.formatTimestamp(e.getNextAttemptTimestamp());
|
||||
}
|
||||
throw new UserErrorException(message);
|
||||
} catch (CaptchaRequiredException e) {
|
||||
String message;
|
||||
if (captcha == null) {
|
||||
|
@ -76,6 +84,10 @@ public class RegisterCommand implements RegistrationCommand, JsonRpcRegistration
|
|||
} else {
|
||||
message = "Invalid captcha given.";
|
||||
}
|
||||
if (e.getNextAttemptTimestamp() > 0) {
|
||||
message += "\nNext Captcha may be provided at "
|
||||
+ DateUtils.formatTimestamp(e.getNextAttemptTimestamp());
|
||||
}
|
||||
throw new UserErrorException(message);
|
||||
} catch (NonNormalizedPhoneNumberException e) {
|
||||
throw new UserErrorException("Failed to register: " + e.getMessage(), e);
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.asamk.signal.manager.api.CaptchaRequiredException;
|
|||
import org.asamk.signal.manager.api.IncorrectPinException;
|
||||
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
|
||||
import org.asamk.signal.manager.api.PinLockedException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.UserAlreadyExistsException;
|
||||
import org.freedesktop.dbus.DBusPath;
|
||||
|
||||
|
@ -59,6 +60,9 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
}
|
||||
try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) {
|
||||
registrationManager.register(voiceVerification, captcha);
|
||||
} catch (RateLimitException e) {
|
||||
String message = "Rate limit reached";
|
||||
throw new SignalControl.Error.Failure(message);
|
||||
} catch (CaptchaRequiredException e) {
|
||||
String message = captcha == null ? "Captcha required for verification." : "Invalid captcha given.";
|
||||
throw new SignalControl.Error.RequiresCaptcha(message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue