mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Prevent creation of RecipientAddress with UNKNOWN_UUID
This commit is contained in:
parent
2e01a05e71
commit
656ca6b5e4
2 changed files with 4 additions and 5 deletions
|
@ -18,6 +18,7 @@ public class RecipientAddress {
|
||||||
* @param e164 The phone number of the user, if available.
|
* @param e164 The phone number of the user, if available.
|
||||||
*/
|
*/
|
||||||
public RecipientAddress(Optional<UUID> uuid, Optional<String> e164) {
|
public RecipientAddress(Optional<UUID> uuid, Optional<String> e164) {
|
||||||
|
uuid = uuid.isPresent() && uuid.get().equals(UuidUtil.UNKNOWN_UUID) ? Optional.empty() : uuid;
|
||||||
if (!uuid.isPresent() && !e164.isPresent()) {
|
if (!uuid.isPresent() && !e164.isPresent()) {
|
||||||
throw new AssertionError("Must have either a UUID or E164 number!");
|
throw new AssertionError("Must have either a UUID or E164 number!");
|
||||||
}
|
}
|
||||||
|
@ -31,13 +32,11 @@ public class RecipientAddress {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecipientAddress(SignalServiceAddress address) {
|
public RecipientAddress(SignalServiceAddress address) {
|
||||||
this.uuid = Optional.of(address.getUuid());
|
this(Optional.of(address.getUuid()), Optional.ofNullable(address.getNumber().orNull()));
|
||||||
this.e164 = Optional.ofNullable(address.getNumber().orNull());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecipientAddress(UUID uuid) {
|
public RecipientAddress(UUID uuid) {
|
||||||
this.uuid = Optional.of(uuid);
|
this(Optional.of(uuid), Optional.empty());
|
||||||
this.e164 = Optional.empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getNumber() {
|
public Optional<String> getNumber() {
|
||||||
|
|
|
@ -308,7 +308,7 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
||||||
final var byNumber = address.getNumber().isEmpty()
|
final var byNumber = address.getNumber().isEmpty()
|
||||||
? Optional.<Recipient>empty()
|
? Optional.<Recipient>empty()
|
||||||
: findByNumberLocked(address.getNumber().get());
|
: findByNumberLocked(address.getNumber().get());
|
||||||
final var byUuid = address.getUuid().isEmpty() || address.getUuid().get().equals(UuidUtil.UNKNOWN_UUID)
|
final var byUuid = address.getUuid().isEmpty()
|
||||||
? Optional.<Recipient>empty()
|
? Optional.<Recipient>empty()
|
||||||
: findByUuidLocked(address.getUuid().get());
|
: findByUuidLocked(address.getUuid().get());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue