]> Untitled Git - lemmy.git/blobdiff - crates/db_views/src/post_view.rs
Hide community v2 (#2055)
[lemmy.git] / crates / db_views / src / post_view.rs
index 14138374a146f837f623eb5ed11214c4df54c086..b9350f8fc0e159a37edf1c5f3e43da6f98158a78 100644 (file)
@@ -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 {