diff --git a/src/db.rs b/src/db.rs index b020187..a4f648e 100644 --- a/src/db.rs +++ b/src/db.rs @@ -11,6 +11,8 @@ use crate::repo::NostrRepo; use crate::server::NostrMetrics; use governor::clock::Clock; use governor::{Quota, RateLimiter}; +use nostr::key::FromPkStr; +use nostr::key::Keys; use r2d2; use sqlx::pool::PoolOptions; use sqlx::postgres::PgConnectOptions; @@ -20,8 +22,6 @@ use std::thread; use std::time::{Duration, Instant}; use tracing::log::LevelFilter; use tracing::{debug, info, trace, warn}; -use nostr::key::FromPkStr; -use nostr::key::Keys; pub type SqlitePool = r2d2::Pool; pub type PooledConnection = r2d2::PooledConnection; @@ -303,7 +303,10 @@ pub async fn db_writer( continue; } } - Err(Error::SqlError(rusqlite::Error::QueryReturnedNoRows)) => { + Err( + Error::SqlError(rusqlite::Error::QueryReturnedNoRows) + | Error::SqlxError(sqlx::Error::RowNotFound), + ) => { debug!( "no verification records found for pubkey: {:?}", event.get_author_prefix() diff --git a/src/nip05.rs b/src/nip05.rs index 5e1f35b..414db3a 100644 --- a/src/nip05.rs +++ b/src/nip05.rs @@ -384,7 +384,10 @@ impl Verifier { } } } - Err(Error::SqlError(rusqlite::Error::QueryReturnedNoRows)) => { + Err( + Error::SqlError(rusqlite::Error::QueryReturnedNoRows) + | Error::SqlxError(sqlx::Error::RowNotFound), + ) => { // No users need verification. Reset the interval to // the next verification attempt. let start = tokio::time::Instant::now() + self.wait_after_finish; diff --git a/src/repo/postgres.rs b/src/repo/postgres.rs index 93b5a43..6e8fea6 100644 --- a/src/repo/postgres.rs +++ b/src/repo/postgres.rs @@ -950,7 +950,10 @@ impl FromRow<'_, PgRow> for VerificationRecord { address: hex::encode(row.get::<'_, Vec, &str>("pub_key")), event: hex::encode(row.get::<'_, Vec, &str>("event_id")), event_created: row.get::<'_, DateTime, &str>("created_at").timestamp() as u64, - last_success: None, + last_success: match row.try_get::<'_, DateTime, &str>("verified_at") { + Ok(x) => Some(x.timestamp() as u64), + _ => None, + }, last_failure: match row.try_get::<'_, DateTime, &str>("failed_at") { Ok(x) => Some(x.timestamp() as u64), _ => None,