Handle unregistered username correctly when sending message

Fixes #1824
This commit is contained in:
AsamK 2025-09-14 17:38:19 +02:00
parent e60b80effc
commit 371dc06842
3 changed files with 9 additions and 4 deletions

View File

@ -1137,7 +1137,7 @@
"allDeclaredFields":true,
"queryAllDeclaredMethods":true,
"queryAllDeclaredConstructors":true,
"methods":[{"name":"number","parameterTypes":[] }, {"name":"uuid","parameterTypes":[] }]
"methods":[{"name":"number","parameterTypes":[] }, {"name":"username","parameterTypes":[] }, {"name":"uuid","parameterTypes":[] }]
},
{
"name":"org.asamk.signal.json.JsonRemoteDelete",

View File

@ -95,7 +95,10 @@ public class RecipientHelper {
try {
return resolveRecipientByUsernameOrLink(username, false);
} catch (Exception e) {
return null;
throw new UnregisteredRecipientException(new org.asamk.signal.manager.api.RecipientAddress(null,
null,
null,
username));
}
}
throw new AssertionError("Unexpected RecipientIdentifier: " + recipient);

View File

@ -4,9 +4,11 @@ import org.asamk.signal.manager.api.RecipientAddress;
import java.util.UUID;
public record JsonRecipientAddress(String uuid, String number) {
public record JsonRecipientAddress(String uuid, String number, String username) {
public static JsonRecipientAddress from(RecipientAddress address) {
return new JsonRecipientAddress(address.uuid().map(UUID::toString).orElse(null), address.number().orElse(null));
return new JsonRecipientAddress(address.uuid().map(UUID::toString).orElse(null),
address.number().orElse(null),
address.username().orElse(null));
}
}