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

Commit 8cb4f3c

Browse files
committed
Add delete profile
1 parent 8345bb4 commit 8cb4f3c

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

mutiny-core/src/nostr/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,21 @@ impl<S: MutinyStorage> NostrManager<S> {
318318
Ok(with_nip05)
319319
}
320320

321+
/// Sets the user's nostr profile metadata as deleted
322+
pub async fn delete_profile(&self) -> Result<Metadata, MutinyError> {
323+
let metadata = Metadata::default()
324+
.name("Deleted")
325+
.display_name("Deleted")
326+
.about("Deleted")
327+
.custom_field("deleted", true);
328+
329+
let event_id = self.client.set_metadata(&metadata).await?;
330+
log_info!(self.logger, "New kind 0: {event_id}");
331+
self.storage.set_nostr_profile(metadata.clone())?;
332+
333+
Ok(metadata)
334+
}
335+
321336
pub fn get_profile(&self) -> Result<Metadata, MutinyError> {
322337
Ok(self.storage.get_nostr_profile()?.unwrap_or_default())
323338
}

mutiny-wasm/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,13 @@ impl MutinyWallet {
18821882
Ok(JsValue::from_serde(&profile)?)
18831883
}
18841884

1885+
/// Sets the user's nostr profile data to a "deleted" state
1886+
#[wasm_bindgen]
1887+
pub async fn delete_profile(&self) -> Result<JsValue, MutinyJsError> {
1888+
let profile = self.inner.nostr.delete_profile().await?;
1889+
Ok(JsValue::from_serde(&profile)?)
1890+
}
1891+
18851892
/// Syncs all of our nostr data from the configured primal instance
18861893
pub async fn sync_nostr(&self) -> Result<(), MutinyJsError> {
18871894
self.inner.sync_nostr().await?;

0 commit comments

Comments
 (0)