]> Untitled Git - lemmy.git/commitdiff
Fix Hidden communities showing in community list (#3094)
authorAlex Maras <dev@alexmaras.com>
Thu, 15 Jun 2023 11:39:58 +0000 (19:39 +0800)
committerGitHub <noreply@github.com>
Thu, 15 Jun 2023 11:39:58 +0000 (13:39 +0200)
* Only show hidden communities when explicitly searching for them rather then in "all"

* dont set hidden to false when creating and updating - let DB set default

* lint

---------

Co-authored-by: Alex Maras <alexmaras@gmail.com>
crates/apub/src/protocol/objects/group.rs
crates/db_views_actor/src/community_view.rs

index f077a501100b409ed1f14e71c599ec3f57d443ba..2b32915afa62be879fe077875b1a6513d396caa5 100644 (file)
@@ -112,7 +112,7 @@ impl Group {
       actor_id: Some(self.id.into()),
       local: Some(false),
       private_key: None,
-      hidden: Some(false),
+      hidden: None,
       public_key: self.public_key.public_key_pem,
       last_refreshed_at: Some(naive_now()),
       icon: self.icon.map(|i| i.url.into()),
@@ -143,7 +143,7 @@ impl Group {
       actor_id: Some(self.id.into()),
       local: None,
       private_key: None,
-      hidden: Some(false),
+      hidden: None,
       public_key: Some(self.public_key.public_key_pem),
       last_refreshed_at: Some(naive_now()),
       icon: Some(self.icon.map(|i| i.url.into())),
index abab023a66ac7efa122000170a7c15bad9ce956b..ee6066c22d95a836b82c7d84ef5cffdaa0c971db 100644 (file)
@@ -173,22 +173,19 @@ impl<'a> CommunityQuery<'a> {
     if !self.is_mod_or_admin.unwrap_or(true) {
       query = query
         .filter(community::removed.eq(false))
-        .filter(community::deleted.eq(false));
+        .filter(community::deleted.eq(false))
+        .filter(
+          community::hidden
+            .eq(false)
+            .or(community_follower::person_id.eq(person_id_join)),
+        );
     }
 
     match self.sort.unwrap_or(SortType::Hot) {
       SortType::New => query = query.order_by(community::published.desc()),
       SortType::TopAll => query = query.order_by(community_aggregates::subscribers.desc()),
       SortType::TopMonth => query = query.order_by(community_aggregates::users_active_month.desc()),
-      SortType::Hot => {
-        query = query.order_by(community_aggregates::hot_rank.desc());
-        // Don't show hidden communities in Hot (trending)
-        query = query.filter(
-          community::hidden
-            .eq(false)
-            .or(community_follower::person_id.eq(person_id_join)),
-        );
-      }
+      SortType::Hot => query = query.order_by(community_aggregates::hot_rank.desc()),
       // Covers all other sorts
       _ => query = query.order_by(community_aggregates::users_active_month.desc()),
     };