add: reposts/quotes pages
add: repost notification
This commit is contained in:
parent
41250ef7ed
commit
276f25a496
17 changed files with 601 additions and 50 deletions
|
@ -42,12 +42,18 @@ pub async fn index_request(
|
|||
}
|
||||
};
|
||||
|
||||
let ignore_users = data.0.get_userblocks_receivers(user.id).await;
|
||||
|
||||
let list = match data
|
||||
.0
|
||||
.get_posts_from_user_communities(user.id, 12, req.page)
|
||||
.await
|
||||
{
|
||||
Ok(l) => match data.0.fill_posts_with_community(l, user.id).await {
|
||||
Ok(l) => match data
|
||||
.0
|
||||
.fill_posts_with_community(l, user.id, &ignore_users)
|
||||
.await
|
||||
{
|
||||
Ok(l) => l,
|
||||
Err(e) => return Html(render_error(e, &jar, &data, &Some(user)).await),
|
||||
},
|
||||
|
@ -71,10 +77,20 @@ pub async fn popular_request(
|
|||
let data = data.read().await;
|
||||
let user = get_user_from_token!(jar, data.0);
|
||||
|
||||
let ignore_users = if let Some(ref ua) = user {
|
||||
data.0.get_userblocks_receivers(ua.id).await
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
let list = match data.0.get_popular_posts(12, req.page, 604_800_000).await {
|
||||
Ok(l) => match data
|
||||
.0
|
||||
.fill_posts_with_community(l, if let Some(ref ua) = user { ua.id } else { 0 })
|
||||
.fill_posts_with_community(
|
||||
l,
|
||||
if let Some(ref ua) = user { ua.id } else { 0 },
|
||||
&ignore_users,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(l) => l,
|
||||
|
@ -107,12 +123,18 @@ pub async fn following_request(
|
|||
}
|
||||
};
|
||||
|
||||
let ignore_users = data.0.get_userblocks_receivers(user.id).await;
|
||||
|
||||
let list = match data
|
||||
.0
|
||||
.get_posts_from_user_following(user.id, 12, req.page)
|
||||
.await
|
||||
{
|
||||
Ok(l) => match data.0.fill_posts_with_community(l, user.id).await {
|
||||
Ok(l) => match data
|
||||
.0
|
||||
.fill_posts_with_community(l, user.id, &ignore_users)
|
||||
.await
|
||||
{
|
||||
Ok(l) => l,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
},
|
||||
|
@ -138,10 +160,20 @@ pub async fn all_request(
|
|||
let data = data.read().await;
|
||||
let user = get_user_from_token!(jar, data.0);
|
||||
|
||||
let ignore_users = if let Some(ref ua) = user {
|
||||
data.0.get_userblocks_receivers(ua.id).await
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
let list = match data.0.get_latest_posts(12, req.page).await {
|
||||
Ok(l) => match data
|
||||
.0
|
||||
.fill_posts_with_community(l, if let Some(ref ua) = user { ua.id } else { 0 })
|
||||
.fill_posts_with_community(
|
||||
l,
|
||||
if let Some(ref ua) = user { ua.id } else { 0 },
|
||||
&ignore_users,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(l) => l,
|
||||
|
@ -172,12 +204,14 @@ pub async fn index_questions_request(
|
|||
}
|
||||
};
|
||||
|
||||
let ignore_users = data.0.get_userblocks_receivers(user.id).await;
|
||||
|
||||
let list = match data
|
||||
.0
|
||||
.get_questions_from_user_communities(user.id, 12, req.page)
|
||||
.await
|
||||
{
|
||||
Ok(l) => match data.0.fill_questions(l).await {
|
||||
Ok(l) => match data.0.fill_questions(l, &ignore_users).await {
|
||||
Ok(l) => l,
|
||||
Err(e) => return Html(render_error(e, &jar, &data, &Some(user)).await),
|
||||
},
|
||||
|
@ -210,12 +244,14 @@ pub async fn popular_questions_request(
|
|||
}
|
||||
};
|
||||
|
||||
let ignore_users = data.0.get_userblocks_receivers(user.id).await;
|
||||
|
||||
let list = match data
|
||||
.0
|
||||
.get_popular_global_questions(12, req.page, 604_800_000)
|
||||
.await
|
||||
{
|
||||
Ok(l) => match data.0.fill_questions(l).await {
|
||||
Ok(l) => match data.0.fill_questions(l, &ignore_users).await {
|
||||
Ok(l) => l,
|
||||
Err(e) => return Html(render_error(e, &jar, &data, &Some(user)).await),
|
||||
},
|
||||
|
@ -250,12 +286,14 @@ pub async fn following_questions_request(
|
|||
}
|
||||
};
|
||||
|
||||
let ignore_users = data.0.get_userblocks_receivers(user.id).await;
|
||||
|
||||
let list = match data
|
||||
.0
|
||||
.get_questions_from_user_following(user.id, 12, req.page)
|
||||
.await
|
||||
{
|
||||
Ok(l) => match data.0.fill_questions(l).await {
|
||||
Ok(l) => match data.0.fill_questions(l, &ignore_users).await {
|
||||
Ok(l) => l,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
},
|
||||
|
@ -283,8 +321,14 @@ pub async fn all_questions_request(
|
|||
let data = data.read().await;
|
||||
let user = get_user_from_token!(jar, data.0);
|
||||
|
||||
let ignore_users = if let Some(ref ua) = user {
|
||||
data.0.get_userblocks_receivers(ua.id).await
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
let list = match data.0.get_latest_global_questions(12, req.page).await {
|
||||
Ok(l) => match data.0.fill_questions(l).await {
|
||||
Ok(l) => match data.0.fill_questions(l, &ignore_users).await {
|
||||
Ok(l) => l,
|
||||
Err(e) => return Html(render_error(e, &jar, &data, &user).await),
|
||||
},
|
||||
|
@ -353,24 +397,31 @@ pub async fn requests_request(
|
|||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
};
|
||||
|
||||
let ignore_users = data.0.get_userblocks_receivers(user.id).await;
|
||||
|
||||
let questions = match data
|
||||
.0
|
||||
.fill_questions({
|
||||
let mut q = Vec::new();
|
||||
.fill_questions(
|
||||
{
|
||||
let mut q = Vec::new();
|
||||
|
||||
for req in &requests {
|
||||
if req.action_type != ActionType::Answer {
|
||||
continue;
|
||||
for req in &requests {
|
||||
if req.action_type != ActionType::Answer {
|
||||
continue;
|
||||
}
|
||||
|
||||
q.push(match data.0.get_question_by_id(req.linked_asset).await {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
return Err(Html(render_error(e, &jar, &data, &Some(user)).await));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
q.push(match data.0.get_question_by_id(req.linked_asset).await {
|
||||
Ok(p) => p,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
});
|
||||
}
|
||||
|
||||
q
|
||||
})
|
||||
q
|
||||
},
|
||||
&ignore_users,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(q) => q,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue