Fix Hidden communities showing in community list (#3094)

* 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>
pull/3135/head
Alex Maras 2023-06-15 19:39:58 +08:00 committed by GitHub
parent b5dba17426
commit becf75d1f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -112,7 +112,7 @@ impl Group {
actor_id: Some(self.id.into()), actor_id: Some(self.id.into()),
local: Some(false), local: Some(false),
private_key: None, private_key: None,
hidden: Some(false), hidden: None,
public_key: self.public_key.public_key_pem, public_key: self.public_key.public_key_pem,
last_refreshed_at: Some(naive_now()), last_refreshed_at: Some(naive_now()),
icon: self.icon.map(|i| i.url.into()), icon: self.icon.map(|i| i.url.into()),
@ -143,7 +143,7 @@ impl Group {
actor_id: Some(self.id.into()), actor_id: Some(self.id.into()),
local: None, local: None,
private_key: None, private_key: None,
hidden: Some(false), hidden: None,
public_key: Some(self.public_key.public_key_pem), public_key: Some(self.public_key.public_key_pem),
last_refreshed_at: Some(naive_now()), last_refreshed_at: Some(naive_now()),
icon: Some(self.icon.map(|i| i.url.into())), icon: Some(self.icon.map(|i| i.url.into())),

View File

@ -173,22 +173,19 @@ impl<'a> CommunityQuery<'a> {
if !self.is_mod_or_admin.unwrap_or(true) { if !self.is_mod_or_admin.unwrap_or(true) {
query = query query = query
.filter(community::removed.eq(false)) .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) { match self.sort.unwrap_or(SortType::Hot) {
SortType::New => query = query.order_by(community::published.desc()), SortType::New => query = query.order_by(community::published.desc()),
SortType::TopAll => query = query.order_by(community_aggregates::subscribers.desc()), SortType::TopAll => query = query.order_by(community_aggregates::subscribers.desc()),
SortType::TopMonth => query = query.order_by(community_aggregates::users_active_month.desc()), SortType::TopMonth => query = query.order_by(community_aggregates::users_active_month.desc()),
SortType::Hot => { SortType::Hot => query = query.order_by(community_aggregates::hot_rank.desc()),
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)),
);
}
// Covers all other sorts // Covers all other sorts
_ => query = query.order_by(community_aggregates::users_active_month.desc()), _ => query = query.order_by(community_aggregates::users_active_month.desc()),
}; };