return new Uuid(UUID.fromString(identifier));
}
+ if (identifier.startsWith("PNI:")) {
+ final var pni = identifier.substring(4);
+ if (!UuidUtil.isUuid(pni)) {
+ throw new InvalidNumberException("Invalid PNI");
+ }
+ return new Pni(UUID.fromString(pni));
+ }
+
if (identifier.startsWith("u:")) {
return new Username(identifier.substring(2));
}
} else if (address.aci().isPresent()) {
return new Uuid(UUID.fromString(address.aci().get()));
} else if (address.pni().isPresent()) {
- return new Pni(address.pni().get());
+ return new Pni(UUID.fromString(address.pni().get().substring(4)));
} else if (address.username().isPresent()) {
return new Username(address.username().get());
}
}
}
- record Pni(String pni) implements Single {
+ record Pni(UUID pni) implements Single {
@Override
public String getIdentifier() {
- return pni;
+ return "PNI:" + pni.toString();
}
@Override
public RecipientAddress toPartialRecipientAddress() {
- return new RecipientAddress(null, pni, null, null);
+ return new RecipientAddress(null, getIdentifier(), null, null);
}
}
if (recipient instanceof RecipientIdentifier.Uuid uuidRecipient) {
return account.getRecipientResolver().resolveRecipient(ACI.from(uuidRecipient.uuid()));
} else if (recipient instanceof RecipientIdentifier.Pni pniRecipient) {
- return account.getRecipientResolver().resolveRecipient(PNI.parseOrThrow(pniRecipient.pni()));
+ return account.getRecipientResolver().resolveRecipient(PNI.from(pniRecipient.pni()));
} else if (recipient instanceof RecipientIdentifier.Number numberRecipient) {
final var number = numberRecipient.number();
return account.getRecipientStore().resolveRecipientByNumber(number, () -> {
.deleteEntryForRecipientNonGroup(targetSentTimestamp, ACI.from(u.uuid()));
} else if (recipient instanceof RecipientIdentifier.Pni pni) {
account.getMessageSendLogStore()
- .deleteEntryForRecipientNonGroup(targetSentTimestamp, PNI.parseOrThrow(pni.pni()));
+ .deleteEntryForRecipientNonGroup(targetSentTimestamp, PNI.from(pni.pni()));
} else if (recipient instanceof RecipientIdentifier.Single r) {
try {
final var recipientId = context.getRecipientHelper().resolveRecipient(r);
}
public RecipientAddress(org.asamk.signal.manager.api.RecipientAddress address) {
- this(address.aci().map(ACI::parseOrNull),
- address.pni().map(PNI::parseOrNull),
+ this(address.aci().map(ACI::parseOrThrow),
+ address.pni().map(PNI::parseOrThrow),
address.number(),
address.username());
}