Skip to content
This repository has been archived by the owner on Feb 3, 2025. It is now read-only.

Commit

Permalink
Merge pull request #1096 from MutinyWallet/delete-profile
Browse files Browse the repository at this point in the history
Add delete profile
  • Loading branch information
AnthonyRonning authored Mar 28, 2024
2 parents 8345bb4 + 8cb4f3c commit 25be60d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mutiny-core/src/nostr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,21 @@ impl<S: MutinyStorage> NostrManager<S> {
Ok(with_nip05)
}

/// Sets the user's nostr profile metadata as deleted
pub async fn delete_profile(&self) -> Result<Metadata, MutinyError> {
let metadata = Metadata::default()
.name("Deleted")
.display_name("Deleted")
.about("Deleted")
.custom_field("deleted", true);

let event_id = self.client.set_metadata(&metadata).await?;
log_info!(self.logger, "New kind 0: {event_id}");
self.storage.set_nostr_profile(metadata.clone())?;

Ok(metadata)
}

pub fn get_profile(&self) -> Result<Metadata, MutinyError> {
Ok(self.storage.get_nostr_profile()?.unwrap_or_default())
}
Expand Down
7 changes: 7 additions & 0 deletions mutiny-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,13 @@ impl MutinyWallet {
Ok(JsValue::from_serde(&profile)?)
}

/// Sets the user's nostr profile data to a "deleted" state
#[wasm_bindgen]
pub async fn delete_profile(&self) -> Result<JsValue, MutinyJsError> {
let profile = self.inner.nostr.delete_profile().await?;
Ok(JsValue::from_serde(&profile)?)
}

/// Syncs all of our nostr data from the configured primal instance
pub async fn sync_nostr(&self) -> Result<(), MutinyJsError> {
self.inner.sync_nostr().await?;
Expand Down

0 comments on commit 25be60d

Please sign in to comment.