add: outbox tab on profile
tab is only visible to profile owner and mods
This commit is contained in:
parent
5dec98d698
commit
7bda718082
12 changed files with 264 additions and 9 deletions
|
@ -387,10 +387,17 @@ pub async fn notifications_request(
|
|||
))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RequestsProps {
|
||||
#[serde(default)]
|
||||
pub id: usize,
|
||||
}
|
||||
|
||||
/// `/requests`
|
||||
pub async fn requests_request(
|
||||
jar: CookieJar,
|
||||
Extension(data): Extension<State>,
|
||||
Query(props): Query<RequestsProps>,
|
||||
) -> impl IntoResponse {
|
||||
let data = data.read().await;
|
||||
let user = match get_user_from_token!(jar, data.0) {
|
||||
|
@ -402,7 +409,20 @@ pub async fn requests_request(
|
|||
}
|
||||
};
|
||||
|
||||
let requests = match data.0.get_requests_by_owner(user.id).await {
|
||||
let profile = if props.id != 0 {
|
||||
match data.0.get_user_by_id(props.id).await {
|
||||
Ok(p) => p,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &None).await)),
|
||||
}
|
||||
} else {
|
||||
user.clone()
|
||||
};
|
||||
|
||||
let requests = match data
|
||||
.0
|
||||
.get_requests_by_owner(if props.id != 0 { props.id } else { user.id })
|
||||
.await
|
||||
{
|
||||
Ok(p) => p,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
};
|
||||
|
@ -448,6 +468,8 @@ pub async fn requests_request(
|
|||
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0, lang, &Some(user)).await;
|
||||
|
||||
context.insert("profile", &profile);
|
||||
context.insert("requests", &requests);
|
||||
context.insert("questions", &questions);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue