fix: return no relay address for key-contacts without an address

`relay_addrs()` fell back to the contact address even when it is empty,
which happens for key-contacts created from a sync message or for the
self-contact, putting an empty string into the SMTP recipient list.
This commit is contained in:
holger krekel
2026-08-29 20:36:22 +02:00
parent f162749dfe
commit 3d61e0f349

View File

@@ -474,7 +474,18 @@ pub(crate) fn addresses_from_public_key(public_key: &SignedPublicKey) -> Option<
/// Returns the addresses to reach the owner of `public_key`,
/// falling back to `addr` if the key carries no relay list.
pub(crate) fn relay_addrs(public_key: &SignedPublicKey, addr: &str) -> Vec<String> {
addresses_from_public_key(public_key).unwrap_or_else(|| vec![addr.to_string()])
addresses_from_public_key(public_key).unwrap_or_else(|| {
if addr.is_empty() {
vec![]
} else {
vec![addr.to_string()]
}
})
}
/// Returns true if the key can be encrypted to, i.e. has an encryption subkey.
pub(crate) fn pubkey_can_encrypt(public_key: &SignedPublicKey) -> bool {
select_pk_for_encryption(public_key).is_some()
}
/// Returns true if public key advertises SEIPDv2 feature.