use poem::web::Data; use sqlx::SqlitePool; use crate::{ authentication::Authentication, subsonic::{self, SubsonicResponse}, user, }; #[poem::handler] pub async fn ping(Data(pool): Data<&SqlitePool>, auth: Authentication) -> SubsonicResponse { let user = user::get_user(pool, &auth.username).await; match user { Ok(Some(u)) => { if u.verify(&auth.token, &auth.salt) { SubsonicResponse::new_empty() } else { SubsonicResponse::new_error(subsonic::Error::WrongUsernameOrPassword(None)) } } Ok(None) => SubsonicResponse::new_error(subsonic::Error::WrongUsernameOrPassword(None)), Err(e) => { tracing::error!("Error getting user: {}", e); SubsonicResponse::new_error(subsonic::Error::WrongUsernameOrPassword(None)) } } }