feat: get account info

This commit is contained in:
2025-02-21 11:43:39 +00:00
parent 2348c9d851
commit f45e6cbdc9
2 changed files with 18 additions and 1 deletions

View File

@ -63,7 +63,7 @@ impl LNVpsDb for LNVpsDbMysql {
.bind(user.contact_nip17)
.bind(user.contact_email)
.bind(user.id)
.fetch_one(&self.db)
.execute(&self.db)
.await?;
Ok(())
}

View File

@ -18,6 +18,7 @@ use ws::Message;
pub fn routes() -> Vec<Route> {
routes![
v1_get_account,
v1_patch_account,
v1_list_vms,
v1_get_vm,
@ -103,6 +104,22 @@ async fn v1_patch_account(
ApiData::ok(())
}
#[get("/api/v1/account")]
async fn v1_get_account(
auth: Nip98Auth,
db: &State<Box<dyn LNVpsDb>>,
) -> ApiResult<AccountPatchRequest> {
let pubkey = auth.event.pubkey.to_bytes();
let uid = db.upsert_user(&pubkey).await?;
let mut user = db.get_user(uid).await?;
ApiData::ok(AccountPatchRequest {
email: user.email,
contact_nip17: user.contact_nip17,
contact_email: user.contact_email,
})
}
#[get("/api/v1/vm")]
async fn v1_list_vms(
auth: Nip98Auth,