From 6767500ea2fd8ef41d547b4532d8e4fca134223e Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 23 Oct 2026 09:33:03 +0000 Subject: [PATCH] refactor: factor out Contact.relay_addresses() --- src/contact.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/contact.rs b/src/contact.rs index fb6716baa..37860a40a 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -1472,9 +1472,7 @@ WHERE addr=? ); } - if let Some(public_key) = contact.public_key(context).await? - && let Some(relay_addrs) = addresses_from_public_key(&public_key) - { + if let Some(relay_addrs) = contact.relay_addresses(context).await? { ret += "\n\nRelays:"; for relay in &relay_addrs { ret += "\n"; @@ -1604,6 +1602,17 @@ WHERE addr=? } } + /// Returns a list of relay addresses for the contact if it is distributed in the public key. + pub(crate) async fn relay_addresses(&self, context: &Context) -> Result>> { + if let Some(public_key) = self.public_key(context).await? + && let Some(relay_addrs) = addresses_from_public_key(&public_key) + { + Ok(Some(relay_addrs)) + } else { + Ok(None) + } + } + /// Get name authorized by the contact. pub fn get_authname(&self) -> &str { &self.authname