X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_views%2Fsrc%2Fpost_view.rs;h=b9350f8fc0e159a37edf1c5f3e43da6f98158a78;hb=7f9b55e7935f6093895734b1a45ec128d2cb2a33;hp=14138374a146f837f623eb5ed11214c4df54c086;hpb=762b85b27e812856f65933a182188e7102617aae;p=lemmy.git diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 14138374..b9350f8f 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -355,17 +355,32 @@ impl<'a> PostQueryBuilder<'a> { .into_boxed(); if let Some(listing_type) = self.listing_type { - query = match listing_type { - ListingType::Subscribed => query.filter(community_follower::person_id.is_not_null()), - ListingType::Local => query.filter(community::local.eq(true)), - _ => query, - }; - } - - if let Some(community_id) = self.community_id { - query = query - .filter(post::community_id.eq(community_id)) - .then_order_by(post_aggregates::stickied.desc()); + match listing_type { + ListingType::Subscribed => { + query = query.filter(community_follower::person_id.is_not_null()) + } + ListingType::Local => { + query = query.filter(community::local.eq(true)).filter( + community::hidden + .eq(false) + .or(community_follower::person_id.eq(person_id_join)), + ); + } + ListingType::All => { + query = query.filter( + community::hidden + .eq(false) + .or(community_follower::person_id.eq(person_id_join)), + ) + } + ListingType::Community => { + if let Some(community_id) = self.community_id { + query = query + .filter(post::community_id.eq(community_id)) + .then_order_by(post_aggregates::stickied.desc()); + } + } + } } if let Some(community_actor_id) = self.community_actor_id { @@ -679,6 +694,7 @@ mod tests { description: None, updated: None, banner: None, + hidden: false, published: inserted_community.published, }, counts: PostAggregates {