refactor: factor out Contact.relay_addresses()

This commit is contained in:
link2xt
2026-10-24 16:52:41 +00:00
committed by l
parent dedc160a2a
commit 6767500ea2
+12 -3
View File
@@ -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<Option<Vec<String>>> {
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