Repository: LemmyNet/lemmy (language: rust)

Issue:
[Bug]: manually opening a post from a hidden community does not show comments unless you are subscribed
### Requirements

- [x] Is this a bug report? For questions or discussions use https://lemmy.ml/c/lemmy_support
- [x] Did you check to see if this issue already exists?
- [x] Is this only a single bug? Do not put multiple bugs in one issue.
- [x] Do you agree to follow the rules in our [Code of Conduct](https://join-lemmy.org/docs/code_of_conduct.html)?
- [x] Is this a backend issue? Use the [lemmy-ui](https://github.com/LemmyNet/lemmy-ui) repo for UI / frontend issues.

### Summary

I understand hiding the community from the All feed. But if you're going out of your way to manually browse to a post, you probably want to see the comments.

### Steps to Reproduce

1. open https://programming.dev/post/24975603 and see no comments
2. subscribe to community and refresh page
3. now see comments


### Technical Details

no comments (unless you're subscribed, I did subscribe and unsubscribe again to double check both): https://programming.dev/post/24975603

comments visible here: https://lemmy.world/post/25132782

### Version

0.19.5

### Lemmy Instance URL

https://programming.dev/post/24975603


Discussion / hints:
[Relevant code](https://github.com/LemmyNet/lemmy/blob/main/crates/db_views/src/comment/comment_view.rs#L203)

We're hiding posts from the main feed if its hidden and unsubscribed, so we're doing the same for comments. I guess I'll remove the is_subscribed check there, but I don't like that post and comments have different rules now.

Fix patch:
diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs
index 7aa509ec83..c9564d593f 100644
--- a/crates/apub/src/objects/community.rs
+++ b/crates/apub/src/objects/community.rs
@@ -134,7 +134,6 @@ impl Object for ApubCommunity {
   }
 
   /// Converts a `Group` to `Community`, inserts it into the database and updates moderators.
-
   async fn from_json(group: Group, context: &Data<Self::DataType>) -> LemmyResult<ApubCommunity> {
     let instance_id = fetch_instance_actor_for_object(&group.id, context).await?;
 
diff --git a/crates/db_views/src/comment/comment_view.rs b/crates/db_views/src/comment/comment_view.rs
index 04bc56c164..0ffdeac18f 100644
--- a/crates/db_views/src/comment/comment_view.rs
+++ b/crates/db_views/src/comment/comment_view.rs
@@ -199,18 +199,14 @@ impl CommentQuery<'_> {
 
     let is_subscribed = community_actions::followed.is_not_null();
 
-    match o.listing_type.unwrap_or_default() {
-      ListingType::Subscribed => query = query.filter(is_subscribed), /* TODO could be this: and(community_follower::person_id.eq(person_id_join)), */
-      ListingType::Local => {
-        query = query
-          .filter(community::local.eq(true))
-          .filter(community::hidden.eq(false).or(is_subscribed))
-      }
-      ListingType::All => query = query.filter(community::hidden.eq(false).or(is_subscribed)),
-      ListingType::ModeratorView => {
-        query = query.filter(community_actions::became_moderator.is_not_null());
-      }
-    }
+    // For posts, we only show hidden if its subscribed, but for comments,
+    // we ignore hidden.
+    query = match o.listing_type.unwrap_or_default() {
+      ListingType::Subscribed => query.filter(is_subscribed),
+      ListingType::Local => query.filter(community::local.eq(true)),
+      ListingType::All => query,
+      ListingType::ModeratorView => query.filter(community_actions::became_moderator.is_not_null()),
+    };
 
     if let Some(my_id) = my_person_id {
       let not_creator_filter = comment::creator_id.ne(my_id);


Test patch: