mirror of
https://github.com/chatmail/core.git
synced 2026-10-25 22:37:57 +03:00
refactor: factor out Contact.relay_addresses()
This commit is contained in:
+12
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user