mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Improve dbus register error message if called with invalid number
This commit is contained in:
parent
8bcd8d87d2
commit
5743cf4455
3 changed files with 8 additions and 2 deletions
|
@ -21,6 +21,7 @@ import org.asamk.signal.manager.storage.protocol.SignalProtocolStore;
|
||||||
import org.asamk.signal.manager.storage.recipients.Contact;
|
import org.asamk.signal.manager.storage.recipients.Contact;
|
||||||
import org.asamk.signal.manager.storage.recipients.LegacyRecipientStore;
|
import org.asamk.signal.manager.storage.recipients.LegacyRecipientStore;
|
||||||
import org.asamk.signal.manager.storage.recipients.Profile;
|
import org.asamk.signal.manager.storage.recipients.Profile;
|
||||||
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientStore;
|
import org.asamk.signal.manager.storage.recipients.RecipientStore;
|
||||||
import org.asamk.signal.manager.storage.sessions.SessionStore;
|
import org.asamk.signal.manager.storage.sessions.SessionStore;
|
||||||
|
@ -789,7 +790,7 @@ public class SignalAccount implements Closeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecipientId getSelfRecipientId() {
|
public RecipientId getSelfRecipientId() {
|
||||||
return recipientStore.resolveRecipientTrusted(getSelfAddress());
|
return recipientStore.resolveRecipientTrusted(new RecipientAddress(uuid, username));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEncryptedDeviceName() {
|
public String getEncryptedDeviceName() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ public class BaseConfig {
|
||||||
public final static String PROJECT_NAME = BaseConfig.class.getPackage().getImplementationTitle();
|
public final static String PROJECT_NAME = BaseConfig.class.getPackage().getImplementationTitle();
|
||||||
public final static String PROJECT_VERSION = BaseConfig.class.getPackage().getImplementationVersion();
|
public final static String PROJECT_VERSION = BaseConfig.class.getPackage().getImplementationVersion();
|
||||||
|
|
||||||
final static String USER_AGENT_SIGNAL_ANDROID = "Signal-Android/5.12.4";
|
final static String USER_AGENT_SIGNAL_ANDROID = "Signal-Android/5.22.3";
|
||||||
final static String USER_AGENT_SIGNAL_CLI = PROJECT_NAME == null
|
final static String USER_AGENT_SIGNAL_CLI = PROJECT_NAME == null
|
||||||
? "signal-cli"
|
? "signal-cli"
|
||||||
: PROJECT_NAME + "/" + PROJECT_VERSION;
|
: PROJECT_NAME + "/" + PROJECT_VERSION;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.whispersystems.libsignal.util.Pair;
|
||||||
import org.whispersystems.signalservice.api.KeyBackupServicePinException;
|
import org.whispersystems.signalservice.api.KeyBackupServicePinException;
|
||||||
import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException;
|
import org.whispersystems.signalservice.api.KeyBackupSystemNoDataException;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.CaptchaRequiredException;
|
import org.whispersystems.signalservice.api.push.exceptions.CaptchaRequiredException;
|
||||||
|
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -99,6 +100,10 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
||||||
public void registerWithCaptcha(
|
public void registerWithCaptcha(
|
||||||
final String number, final boolean voiceVerification, final String captcha
|
final String number, final boolean voiceVerification, final String captcha
|
||||||
) throws Error.Failure, Error.InvalidNumber {
|
) throws Error.Failure, Error.InvalidNumber {
|
||||||
|
if (!PhoneNumberFormatter.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)) {
|
try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) {
|
||||||
registrationManager.register(voiceVerification, captcha);
|
registrationManager.register(voiceVerification, captcha);
|
||||||
} catch (CaptchaRequiredException e) {
|
} catch (CaptchaRequiredException e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue