mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-07 15:17:47 +00:00
parent
5c366e14a3
commit
465d9b7ba7
7 changed files with 30 additions and 9 deletions
|
@ -24,6 +24,8 @@ struct SubredditTemplate {
|
|||
/// Whether all fetched posts are filtered (to differentiate between no posts fetched in the first place,
|
||||
/// and all fetched posts being filtered).
|
||||
all_posts_filtered: bool,
|
||||
/// Whether all posts were hidden because they are NSFW (and user has disabled show NSFW)
|
||||
all_posts_hidden_nsfw: bool,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
|
@ -111,12 +113,13 @@ pub async fn community(req: Request<Body>) -> Result<Response<Body>, String> {
|
|||
redirect_url,
|
||||
is_filtered: true,
|
||||
all_posts_filtered: false,
|
||||
all_posts_hidden_nsfw: false,
|
||||
})
|
||||
} else {
|
||||
match Post::fetch(&path, quarantined).await {
|
||||
Ok((mut posts, after)) => {
|
||||
let all_posts_filtered = filter_posts(&mut posts, &filters);
|
||||
|
||||
let all_posts_hidden_nsfw = posts.iter().all(|p| p.flags.nsfw) && setting(&req, "show_nsfw") != "on";
|
||||
template(SubredditTemplate {
|
||||
sub,
|
||||
posts,
|
||||
|
@ -127,6 +130,7 @@ pub async fn community(req: Request<Body>) -> Result<Response<Body>, String> {
|
|||
redirect_url,
|
||||
is_filtered: false,
|
||||
all_posts_filtered,
|
||||
all_posts_hidden_nsfw,
|
||||
})
|
||||
}
|
||||
Err(msg) => match msg.as_str() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue