feat: handle error when publish note

This commit is contained in:
2024-10-11 14:09:15 +07:00
parent adad048873
commit cb6006f596
4 changed files with 43 additions and 12 deletions

View File

@@ -353,7 +353,14 @@ pub async fn login(
{
let keys: Vec<&str> = events
.iter()
.flat_map(|event| event.get_tags_content(TagKind::p()))
.flat_map(|event| {
event
.tags
.iter()
.filter(|t| t.kind() == TagKind::p())
.filter_map(|t| t.content())
.collect::<Vec<&str>>()
})
.collect();
let trusted_list: HashSet<PublicKey> = keys

View File

@@ -372,7 +372,7 @@ pub async fn publish(
// Publish
match client.send_event_builder(builder).await {
Ok(event_id) => Ok(event_id.to_bech32().unwrap()),
Ok(event_id) => Ok(event_id.to_hex()),
Err(err) => Err(err.to_string()),
}
}

View File

@@ -164,7 +164,14 @@ pub async fn process_event(client: &Client, events: Vec<Event>) -> Vec<RichEvent
if !requests.is_empty() {
let ids: Vec<&str> = requests
.iter()
.flat_map(|ev| ev.get_tags_content(TagKind::e()))
.flat_map(|event| {
event
.tags
.iter()
.filter(|t| t.kind() == TagKind::e())
.filter_map(|t| t.content())
.collect::<Vec<&str>>()
})
.collect();
// Remove event if event is deleted by author