mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
feat: is_self_addr(): Employ the config cache to optimize for ConfiguredAddr passed
This commit is contained in:
@@ -944,6 +944,18 @@ impl Context {
|
|||||||
/// Determine whether the specified addr maps to the/a self addr.
|
/// Determine whether the specified addr maps to the/a self addr.
|
||||||
/// Returns `false` if no addresses are configured.
|
/// Returns `false` if no addresses are configured.
|
||||||
pub(crate) async fn is_self_addr(&self, addr: &str) -> Result<bool> {
|
pub(crate) async fn is_self_addr(&self, addr: &str) -> Result<bool> {
|
||||||
|
// Employ the config cache to optimize for `ConfiguredAddr` passed.
|
||||||
|
if !addr.is_empty()
|
||||||
|
&& addr_cmp(
|
||||||
|
addr,
|
||||||
|
&self
|
||||||
|
.get_config(Config::ConfiguredAddr)
|
||||||
|
.await?
|
||||||
|
.unwrap_or_default(),
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
Ok(self
|
Ok(self
|
||||||
.get_all_self_addrs()
|
.get_all_self_addrs()
|
||||||
.await?
|
.await?
|
||||||
|
|||||||
Reference in New Issue
Block a user