feat: stuff
This commit is contained in:
parent
2e2b01990e
commit
6d58fd47a1
11 changed files with 244 additions and 366 deletions
|
|
@ -4,16 +4,19 @@ use crate::error::{Error, Errors};
|
|||
use crate::Pool;
|
||||
use crate::xml::Xml;
|
||||
|
||||
|
||||
#[get("/v1/api/people/<username>")]
|
||||
pub async fn person_exists(database: &State<Pool>, username: &str) -> Result<(), Errors<'static>>{
|
||||
let database = database.inner();
|
||||
|
||||
let exists: bool = sqlx::query_as!(
|
||||
bool,
|
||||
"SELECT EXISTS(SELECT 1 FROM users.users WHERE username = ? )",
|
||||
let exists = sqlx::query!(
|
||||
"SELECT EXISTS(SELECT 1 FROM users WHERE username = $1 ) as exists",
|
||||
username
|
||||
).fetch_one(database)
|
||||
.await
|
||||
.ok()
|
||||
.map(|v| v.exists)
|
||||
.flatten()
|
||||
.unwrap_or(true);
|
||||
|
||||
if exists {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue