add: profile is_verified
add: better profile not found page TODO: use error page for fallback service
This commit is contained in:
parent
7d96a3d20f
commit
5cfca49793
13 changed files with 234 additions and 20 deletions
|
@ -1,7 +1,8 @@
|
|||
use super::{PaginatedQuery, render_error};
|
||||
use crate::{State, assets::initial_context, get_lang, get_user_from_token};
|
||||
use axum::{
|
||||
Extension,
|
||||
extract::Path,
|
||||
extract::{Path, Query},
|
||||
response::{Html, IntoResponse},
|
||||
};
|
||||
use axum_extra::extract::CookieJar;
|
||||
|
@ -10,6 +11,7 @@ use axum_extra::extract::CookieJar;
|
|||
pub async fn posts_request(
|
||||
jar: CookieJar,
|
||||
Path(username): Path<String>,
|
||||
Query(props): Query<PaginatedQuery>,
|
||||
Extension(data): Extension<State>,
|
||||
) -> impl IntoResponse {
|
||||
let data = data.read().await;
|
||||
|
@ -17,12 +19,23 @@ pub async fn posts_request(
|
|||
|
||||
let other_user = match data.0.get_user_by_username(&username).await {
|
||||
Ok(ua) => ua,
|
||||
Err(e) => return Err(Html(e.to_string())),
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &user))),
|
||||
};
|
||||
|
||||
let posts = match data
|
||||
.0
|
||||
.get_posts_by_user(other_user.id, 12, props.page)
|
||||
.await
|
||||
{
|
||||
Ok(p) => p,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &user))),
|
||||
};
|
||||
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0, lang, &user);
|
||||
|
||||
context.insert("profile", &other_user);
|
||||
context.insert("posts", &posts);
|
||||
|
||||
Ok(Html(
|
||||
data.1.render("profile/posts.html", &mut context).unwrap(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue