chore: Remove unused modules and update metadata.rs (#199)

This commit is contained in:
XIAO YU 2024-05-31 14:53:35 +09:00 committed by GitHub
parent 921cf871ee
commit c682a58842
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,4 @@
use super::get_latest_event;
use crate::Nostr;
use keyring::Entry;
use nostr_sdk::prelude::*;
@ -88,7 +89,7 @@ pub async fn get_current_user_profile(state: State<'_, Nostr>) -> Result<String,
.await
{
Ok(events) => {
if let Some(event) = events.first() {
if let Some(event) = get_latest_event(&events) {
if let Ok(metadata) = Metadata::from_json(&event.content) {
Ok(metadata.as_json())
} else {

View File

@ -2,3 +2,5 @@ pub mod event;
pub mod keys;
pub mod metadata;
pub mod relay;
mod utils;
pub use utils::get_latest_event;

View File

@ -0,0 +1,5 @@
use nostr_sdk::Event;
pub fn get_latest_event(events: &[Event]) -> Option<&Event> {
events.iter().max_by_key(|event| event.created_at())
}