diff --git a/mutiny-core/src/nostr/mod.rs b/mutiny-core/src/nostr/mod.rs index 54efa2c3b..d82b43074 100644 --- a/mutiny-core/src/nostr/mod.rs +++ b/mutiny-core/src/nostr/mod.rs @@ -1456,6 +1456,21 @@ impl NostrManager { Ok(self.client.send_event_builder(builder).await?) } + /// Checks if we have recommended the given federation + pub async fn has_recommended_federation( + &self, + federation_id: &FederationId, + ) -> Result { + let filter = Filter::new() + .author(self.public_key) + .identifier(federation_id.to_string()) + .limit(1); + + let events = self.client.get_events_of(vec![filter], None).await?; + + Ok(!events.is_empty()) + } + /// Queries our relays for federation announcements pub async fn discover_federations(&self) -> Result, MutinyError> { // get contacts by npub diff --git a/mutiny-wasm/src/lib.rs b/mutiny-wasm/src/lib.rs index 69e5b50cd..d12ea8de0 100644 --- a/mutiny-wasm/src/lib.rs +++ b/mutiny-wasm/src/lib.rs @@ -1246,6 +1246,20 @@ impl MutinyWallet { Ok(event_id.to_hex()) } + /// Checks if we have recommended the given federation + pub async fn has_recommended_federation( + &self, + federation_id: String, + ) -> Result { + let federation_id = FederationId::from_str(&federation_id) + .map_err(|_| MutinyJsError::InvalidArgumentsError)?; + Ok(self + .inner + .nostr + .has_recommended_federation(&federation_id) + .await?) + } + /// Queries our relays for federation announcements pub async fn discover_federations( &self,