feat: support nip-36
This commit is contained in:
@@ -222,16 +222,15 @@ pub async fn get_event_thread(id: &str, state: State<'_, Nostr>) -> Result<Vec<E
|
||||
#[tauri::command]
|
||||
pub async fn publish(
|
||||
content: &str,
|
||||
tags: Vec<Vec<String>>,
|
||||
tags: Vec<Vec<&str>>,
|
||||
state: State<'_, Nostr>,
|
||||
) -> Result<String, String> {
|
||||
let client = &state.client;
|
||||
let final_tags = tags.into_iter().map(|val| Tag::parse(&val).unwrap());
|
||||
|
||||
if let Ok(event_id) = client.publish_text_note(content, final_tags).await {
|
||||
Ok(event_id.to_bech32().unwrap())
|
||||
} else {
|
||||
Err("Publish text note failed".into())
|
||||
match client.publish_text_note(content, final_tags).await {
|
||||
Ok(event_id) => Ok(event_id.to_bech32().unwrap()),
|
||||
Err(err) => Err(err.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,27 +245,3 @@ pub async fn repost(raw: &str, state: State<'_, Nostr>) -> Result<EventId, Strin
|
||||
Err("Repost failed".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn upvote(raw: &str, state: State<'_, Nostr>) -> Result<EventId, String> {
|
||||
let client = &state.client;
|
||||
let event = Event::from_json(raw).unwrap();
|
||||
|
||||
if let Ok(event_id) = client.like(&event).await {
|
||||
Ok(event_id)
|
||||
} else {
|
||||
Err("Upvote failed".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn downvote(raw: &str, state: State<'_, Nostr>) -> Result<EventId, String> {
|
||||
let client = &state.client;
|
||||
let event = Event::from_json(raw).unwrap();
|
||||
|
||||
if let Ok(event_id) = client.dislike(&event).await {
|
||||
Ok(event_id)
|
||||
} else {
|
||||
Err("Downvote failed".into())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user