Add emails
This commit is contained in:
parent
85c559cfb1
commit
f1089232c3
3 changed files with 27 additions and 3 deletions
17
src/main.rs
17
src/main.rs
|
|
@ -486,8 +486,21 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
async fn home(_: State<Arc<AppState>>, User(_): User) -> Result<Html<String>, Error> {
|
||||
Ok(Html(TEMPLATES.render("home.html", &global_context())?))
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct Mail {
|
||||
mail: String,
|
||||
}
|
||||
|
||||
async fn home(state: State<Arc<AppState>>, User(user): User) -> Result<Html<String>, Error> {
|
||||
let mails = sqlx::query_as!(Mail, "SELECT mail FROM emails WHERE id = $1", user)
|
||||
.fetch_all(&state.db)
|
||||
.await?;
|
||||
|
||||
let mut context = tera::Context::new();
|
||||
context.insert("mails", &mails);
|
||||
context.extend(global_context());
|
||||
|
||||
Ok(Html(TEMPLATES.render("home.html", &context)?))
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue