mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Replace UnregisteredUserException
This commit is contained in:
parent
659761f006
commit
782f96b580
3 changed files with 17 additions and 20 deletions
|
@ -29,7 +29,6 @@ import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentRemo
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent;
|
import org.whispersystems.signalservice.api.messages.SignalServiceContent;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
|
||||||
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
||||||
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
||||||
|
|
||||||
|
@ -121,7 +120,7 @@ public interface Manager extends Closeable {
|
||||||
|
|
||||||
void setRegistrationLockPin(Optional<String> pin) throws IOException, UnauthenticatedResponseException;
|
void setRegistrationLockPin(Optional<String> pin) throws IOException, UnauthenticatedResponseException;
|
||||||
|
|
||||||
Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws UnregisteredUserException;
|
Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws IOException;
|
||||||
|
|
||||||
List<Group> getGroups();
|
List<Group> getGroups();
|
||||||
|
|
||||||
|
@ -175,7 +174,7 @@ public interface Manager extends Closeable {
|
||||||
|
|
||||||
void setContactName(
|
void setContactName(
|
||||||
RecipientIdentifier.Single recipient, String name
|
RecipientIdentifier.Single recipient, String name
|
||||||
) throws NotMasterDeviceException, UnregisteredUserException;
|
) throws NotMasterDeviceException, IOException;
|
||||||
|
|
||||||
void setContactBlocked(
|
void setContactBlocked(
|
||||||
RecipientIdentifier.Single recipient, boolean blocked
|
RecipientIdentifier.Single recipient, boolean blocked
|
||||||
|
|
|
@ -76,7 +76,6 @@ import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
|
||||||
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
||||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||||
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
import org.whispersystems.signalservice.api.util.PhoneNumberFormatter;
|
||||||
|
@ -479,7 +478,7 @@ public class ManagerImpl implements Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws UnregisteredUserException {
|
public Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws IOException {
|
||||||
return profileHelper.getRecipientProfile(resolveRecipient(recipient));
|
return profileHelper.getRecipientProfile(resolveRecipient(recipient));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +705,7 @@ public class ManagerImpl implements Manager {
|
||||||
@Override
|
@Override
|
||||||
public void setContactName(
|
public void setContactName(
|
||||||
RecipientIdentifier.Single recipient, String name
|
RecipientIdentifier.Single recipient, String name
|
||||||
) throws NotMasterDeviceException, UnregisteredUserException {
|
) throws NotMasterDeviceException, IOException {
|
||||||
if (!account.isMasterDevice()) {
|
if (!account.isMasterDevice()) {
|
||||||
throw new NotMasterDeviceException();
|
throw new NotMasterDeviceException();
|
||||||
}
|
}
|
||||||
|
@ -813,11 +812,11 @@ public class ManagerImpl implements Manager {
|
||||||
try {
|
try {
|
||||||
uuidMap = getRegisteredUsers(Set.of(number));
|
uuidMap = getRegisteredUsers(Set.of(number));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new UnregisteredUserException(number, e);
|
throw new IOException(number, e);
|
||||||
}
|
}
|
||||||
final var uuid = uuidMap.get(number);
|
final var uuid = uuidMap.get(number);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
throw new UnregisteredUserException(number, null);
|
throw new IOException(number, null);
|
||||||
}
|
}
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
@ -1134,7 +1133,7 @@ public class ManagerImpl implements Manager {
|
||||||
final RecipientId recipientId;
|
final RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = resolveRecipient(recipient);
|
recipientId = resolveRecipient(recipient);
|
||||||
} catch (UnregisteredUserException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return contactHelper.isContactBlocked(recipientId);
|
return contactHelper.isContactBlocked(recipientId);
|
||||||
|
@ -1164,7 +1163,7 @@ public class ManagerImpl implements Manager {
|
||||||
final RecipientId recipientId;
|
final RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = resolveRecipient(recipient);
|
recipientId = resolveRecipient(recipient);
|
||||||
} catch (UnregisteredUserException e) {
|
} catch (IOException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1220,7 +1219,7 @@ public class ManagerImpl implements Manager {
|
||||||
IdentityInfo identity;
|
IdentityInfo identity;
|
||||||
try {
|
try {
|
||||||
identity = account.getIdentityKeyStore().getIdentity(resolveRecipient(recipient));
|
identity = account.getIdentityKeyStore().getIdentity(resolveRecipient(recipient));
|
||||||
} catch (UnregisteredUserException e) {
|
} catch (IOException e) {
|
||||||
identity = null;
|
identity = null;
|
||||||
}
|
}
|
||||||
return identity == null ? List.of() : List.of(toIdentity(identity));
|
return identity == null ? List.of() : List.of(toIdentity(identity));
|
||||||
|
@ -1237,7 +1236,7 @@ public class ManagerImpl implements Manager {
|
||||||
RecipientId recipientId;
|
RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = resolveRecipient(recipient);
|
recipientId = resolveRecipient(recipient);
|
||||||
} catch (UnregisteredUserException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return identityHelper.trustIdentityVerified(recipientId, fingerprint);
|
return identityHelper.trustIdentityVerified(recipientId, fingerprint);
|
||||||
|
@ -1254,7 +1253,7 @@ public class ManagerImpl implements Manager {
|
||||||
RecipientId recipientId;
|
RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = resolveRecipient(recipient);
|
recipientId = resolveRecipient(recipient);
|
||||||
} catch (UnregisteredUserException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return identityHelper.trustIdentityVerifiedSafetyNumber(recipientId, safetyNumber);
|
return identityHelper.trustIdentityVerifiedSafetyNumber(recipientId, safetyNumber);
|
||||||
|
@ -1271,7 +1270,7 @@ public class ManagerImpl implements Manager {
|
||||||
RecipientId recipientId;
|
RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = resolveRecipient(recipient);
|
recipientId = resolveRecipient(recipient);
|
||||||
} catch (UnregisteredUserException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return identityHelper.trustIdentityVerifiedSafetyNumber(recipientId, safetyNumber);
|
return identityHelper.trustIdentityVerifiedSafetyNumber(recipientId, safetyNumber);
|
||||||
|
@ -1287,7 +1286,7 @@ public class ManagerImpl implements Manager {
|
||||||
RecipientId recipientId;
|
RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = resolveRecipient(recipient);
|
recipientId = resolveRecipient(recipient);
|
||||||
} catch (UnregisteredUserException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return identityHelper.trustIdentityAllKeys(recipientId);
|
return identityHelper.trustIdentityAllKeys(recipientId);
|
||||||
|
@ -1324,7 +1323,7 @@ public class ManagerImpl implements Manager {
|
||||||
return resolveSignalServiceAddress(account.getRecipientStore().resolveRecipient(uuid));
|
return resolveSignalServiceAddress(account.getRecipientStore().resolveRecipient(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws UnregisteredUserException {
|
private Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws IOException {
|
||||||
final var recipientIds = new HashSet<RecipientId>(recipients.size());
|
final var recipientIds = new HashSet<RecipientId>(recipients.size());
|
||||||
for (var number : recipients) {
|
for (var number : recipients) {
|
||||||
final var recipientId = resolveRecipient(number);
|
final var recipientId = resolveRecipient(number);
|
||||||
|
@ -1333,7 +1332,7 @@ public class ManagerImpl implements Manager {
|
||||||
return recipientIds;
|
return recipientIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws UnregisteredUserException {
|
private RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws IOException {
|
||||||
if (recipient instanceof RecipientIdentifier.Uuid) {
|
if (recipient instanceof RecipientIdentifier.Uuid) {
|
||||||
return account.getRecipientStore().resolveRecipient(((RecipientIdentifier.Uuid) recipient).uuid);
|
return account.getRecipientStore().resolveRecipient(((RecipientIdentifier.Uuid) recipient).uuid);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.freedesktop.dbus.exceptions.DBusException;
|
||||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||||
import org.freedesktop.dbus.types.Variant;
|
import org.freedesktop.dbus.types.Variant;
|
||||||
import org.whispersystems.signalservice.api.messages.SendMessageResult;
|
import org.whispersystems.signalservice.api.messages.SendMessageResult;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
|
||||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||||
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
||||||
|
|
||||||
|
@ -390,7 +389,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
m.setContactName(getSingleRecipientIdentifier(number, m.getSelfNumber()), name);
|
m.setContactName(getSingleRecipientIdentifier(number, m.getSelfNumber()), name);
|
||||||
} catch (NotMasterDeviceException e) {
|
} catch (NotMasterDeviceException e) {
|
||||||
throw new Error.Failure("This command doesn't work on linked devices.");
|
throw new Error.Failure("This command doesn't work on linked devices.");
|
||||||
} catch (UnregisteredUserException e) {
|
} catch (IOException e) {
|
||||||
throw new Error.Failure("Contact is not registered.");
|
throw new Error.Failure("Contact is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -639,7 +638,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
Profile profile = null;
|
Profile profile = null;
|
||||||
try {
|
try {
|
||||||
profile = m.getRecipientProfile(RecipientIdentifier.Single.fromAddress(address));
|
profile = m.getRecipientProfile(RecipientIdentifier.Single.fromAddress(address));
|
||||||
} catch (UnregisteredUserException ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
if (profile != null && profile.getDisplayName().equals(name)) {
|
if (profile != null && profile.getDisplayName().equals(name)) {
|
||||||
numbers.add(number);
|
numbers.add(number);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue