From 3d61e0f34941c8723af7c4aec333e20fbc0e90f1 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 29 Aug 2026 20:36:22 +0200 Subject: [PATCH] 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. --- src/pgp.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pgp.rs b/src/pgp.rs index 0e3f68c38..6f66a5d82 100644 --- a/src/pgp.rs +++ b/src/pgp.rs @@ -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 { - 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.