add: forum posts timeline
This commit is contained in:
parent
8c779b2f2e
commit
d4ff681310
10 changed files with 159 additions and 17 deletions
|
@ -47,8 +47,8 @@ pub async fn index_request(
|
|||
// i'm only changing this for stripe
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0.0, lang, &None).await;
|
||||
|
||||
context.insert("page", &req.page);
|
||||
|
||||
Html(data.1.render("timelines/all.html", &context).unwrap())
|
||||
};
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ pub async fn index_request(
|
|||
|
||||
context.insert("list", &list);
|
||||
context.insert("page", &req.page);
|
||||
|
||||
Html(data.1.render("timelines/home.html", &context).unwrap())
|
||||
}
|
||||
|
||||
|
@ -93,8 +94,8 @@ pub async fn popular_request(
|
|||
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0.0, lang, &user).await;
|
||||
|
||||
context.insert("page", &req.page);
|
||||
|
||||
Html(data.1.render("timelines/popular.html", &context).unwrap())
|
||||
}
|
||||
|
||||
|
@ -116,8 +117,8 @@ pub async fn following_request(
|
|||
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0.0, lang, &Some(user)).await;
|
||||
|
||||
context.insert("page", &req.page);
|
||||
|
||||
Ok(Html(
|
||||
data.1.render("timelines/following.html", &context).unwrap(),
|
||||
))
|
||||
|
@ -134,8 +135,8 @@ pub async fn all_request(
|
|||
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0.0, lang, &user).await;
|
||||
|
||||
context.insert("page", &req.page);
|
||||
|
||||
Html(data.1.render("timelines/all.html", &context).unwrap())
|
||||
}
|
||||
|
||||
|
@ -172,6 +173,7 @@ pub async fn index_questions_request(
|
|||
|
||||
context.insert("list", &list);
|
||||
context.insert("page", &req.page);
|
||||
|
||||
Html(
|
||||
data.1
|
||||
.render("timelines/home_questions.html", &context)
|
||||
|
@ -212,6 +214,7 @@ pub async fn popular_questions_request(
|
|||
|
||||
context.insert("list", &list);
|
||||
context.insert("page", &req.page);
|
||||
|
||||
Html(
|
||||
data.1
|
||||
.render("timelines/popular_questions.html", &context)
|
||||
|
@ -254,6 +257,7 @@ pub async fn following_questions_request(
|
|||
|
||||
context.insert("list", &list);
|
||||
context.insert("page", &req.page);
|
||||
|
||||
Ok(Html(
|
||||
data.1
|
||||
.render("timelines/following_questions.html", &context)
|
||||
|
@ -271,7 +275,6 @@ pub async fn all_questions_request(
|
|||
let user = get_user_from_token!(jar, data.0);
|
||||
|
||||
let ignore_users = crate::ignore_users_gen!(user, data);
|
||||
|
||||
let list = match data.0.get_latest_global_questions(12, req.page).await {
|
||||
Ok(l) => match data.0.fill_questions(l, &ignore_users).await {
|
||||
Ok(l) => l,
|
||||
|
@ -285,6 +288,7 @@ pub async fn all_questions_request(
|
|||
|
||||
context.insert("list", &list);
|
||||
context.insert("page", &req.page);
|
||||
|
||||
Html(
|
||||
data.1
|
||||
.render("timelines/all_questions.html", &context)
|
||||
|
@ -292,6 +296,50 @@ pub async fn all_questions_request(
|
|||
)
|
||||
}
|
||||
|
||||
/// `/all/forum_posts`
|
||||
pub async fn all_forum_posts_request(
|
||||
jar: CookieJar,
|
||||
Extension(data): Extension<State>,
|
||||
Query(req): Query<PaginatedQuery>,
|
||||
) -> impl IntoResponse {
|
||||
let data = data.read().await;
|
||||
let user = match get_user_from_token!(jar, data.0) {
|
||||
Some(ua) => ua,
|
||||
None => {
|
||||
return Html(render_error(Error::NotAllowed, &jar, &data, &None).await);
|
||||
}
|
||||
};
|
||||
|
||||
let ignore_users = crate::ignore_users_gen!(user!, data);
|
||||
let list = match data
|
||||
.0
|
||||
.get_latest_forum_posts(48, req.page, &Some(user.clone()), req.before)
|
||||
.await
|
||||
{
|
||||
Ok(l) => match data
|
||||
.0
|
||||
.fill_posts_with_community(l, user.id, &ignore_users, &Some(user.clone()))
|
||||
.await
|
||||
{
|
||||
Ok(l) => l,
|
||||
Err(e) => return Html(render_error(e, &jar, &data, &Some(user)).await),
|
||||
},
|
||||
Err(e) => return Html(render_error(e, &jar, &data, &Some(user)).await),
|
||||
};
|
||||
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0.0, lang, &Some(user)).await;
|
||||
|
||||
context.insert("page", &req.page);
|
||||
context.insert("feed", &list);
|
||||
|
||||
Html(
|
||||
data.1
|
||||
.render("timelines/all_forum_posts.html", &context)
|
||||
.unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct NotificationsProps {
|
||||
#[serde(default)]
|
||||
|
|
|
@ -41,6 +41,8 @@ pub fn routes() -> Router {
|
|||
get(misc::following_questions_request),
|
||||
)
|
||||
.route("/all/questions", get(misc::all_questions_request))
|
||||
// forum post timelines
|
||||
.route("/all/forum_posts", get(misc::all_forum_posts_request))
|
||||
// misc
|
||||
.route("/notifs", get(misc::notifications_request))
|
||||
.route("/requests", get(misc::requests_request))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue