This commit is contained in:
Artémis 2025-01-23 00:37:55 +01:00
parent 571e9c8f84
commit 33d952d511
2 changed files with 12 additions and 6 deletions

View file

@ -7,7 +7,7 @@ pub struct DollTags(sqlx::SqlitePool);
pub type DollTagsDb = Connection<DollTags>;
// Doll Profiles stuff
#[derive(Debug)]
#[derive(Debug, Serialise)]
pub struct DollProfile {
pub id: i64,
pub created_at: chrono::NaiveDateTime,

View file

@ -5,6 +5,7 @@ use db::schema::{CreateDollProfile, DollTags, DollTagsDb};
use regex::Regex;
use rocket::form::Form;
use rocket::fs::{relative, FileServer};
use rocket::response::Redirect;
use rocket_db_pools::Database;
use rocket_dyn_templates::{context, Template};
@ -102,16 +103,21 @@ async fn handle_register(db: DollTagsDb, tag: Form<TagForm<'_>>) -> Template {
}
#[get("/profile?<ident>")]
async fn show_profile(db: DollTagsDb, ident: &str) -> Template {
let profile = doll::get(db, 423158).await.expect("fuck");
async fn show_profile(db: DollTagsDb, ident: &str) -> Result<Template, Redirect> {
let internal_id = id_public_to_db(ident).ok_or_else(|| Redirect::to(uri!("/")))?;
let profile = doll::get(db, internal_id).await.expect("fuck");
if let None = profile {
return Err(Redirect::to(uri!("/")));
}
println!("{:?}", profile);
Template::render(
Ok(Template::render(
"show_profile",
context! {
ident,
profile,
},
)
))
}
#[launch]