- 
                Notifications
    
You must be signed in to change notification settings  - Fork 12.4k
 
fix: directory search does not return private channels #37290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: directory search does not return private channels #37290
Conversation
| 
           Looks like this PR is not ready to merge, because of the following issues: 
 Please fix the issues and try again If you have any trouble, please check the PR guidelines  | 
    
          🦋 Changeset detectedLatest commit: af3f3bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 packages
 Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request fixes a regression in v7.7.1 where the Directory search API stopped returning private channels that users are members of. The root cause was the user.__rooms field not being populated by the authentication handler, which is required by the Directory API query to identify joined rooms.
Key Changes:
- Populates the 
user.__roomsfield with a fallback database query if not present - Adds test coverage for private channel directory search functionality
 
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description | 
|---|---|
| apps/meteor/server/methods/browseChannels.ts | Ensures user.__rooms is populated before executing directory search logic | 
| apps/meteor/tests/end-to-end/api/miscellaneous.ts | Adds test case verifying private channels are returned in directory search results | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| 
          
 Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughNarrowed public user parameter types in browseChannels.ts to AtLeast<IUser,'_id'|'__rooms'> and removed an unused IRoom import; the directory route now fetches a projected user (only __rooms) before calling the browse method; tests add a private group, parallelize setup, and extend cleanup. Changes
 Sequence Diagram(s)sequenceDiagram
    actor Client
    participant API as /directory route
    participant UsersDB as Users DB
    participant Browse as browseChannelsMethod
    participant Filter as Channel/Group Filter
    Client->>API: Request directory
    API->>UsersDB: findOneById(userId, projection: { __rooms: 1 })
    UsersDB-->>API: user (includes _id and __rooms)
    API->>Browse: call browseChannelsMethod(user: AtLeast<IUser,'_id'|'__rooms'>)
    Browse->>Browse: use user.__rooms to filter memberships
    alt user.__rooms missing
        Browse->>UsersDB: optionally fetch/populate __rooms
        UsersDB-->>Browse: __rooms populated
    end
    Browse->>Filter: filter channels/groups using membership data
    Filter-->>Browse: results
    Browse-->>API: directory results
    API-->>Client: return results
    Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 
 Suggested reviewers
 Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (4 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Disabled knowledge base sources: 
 
 📒 Files selected for processing (4)
 🚧 Files skipped from review as they are similar to previous changes (1)
 🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-09-25T09:59:26.461ZApplied to files: 
 🧬 Code graph analysis (2)apps/meteor/tests/end-to-end/api/miscellaneous.ts (3)
 apps/meteor/server/methods/browseChannels.ts (2)
 ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
 🔇 Additional comments (10)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment   | 
    
          Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@             Coverage Diff             @@
##           develop   #37290      +/-   ##
===========================================
- Coverage    67.92%   67.92%   -0.01%     
===========================================
  Files         3356     3356              
  Lines       114887   114886       -1     
  Branches     20758    20752       -6     
===========================================
- Hits         78036    78033       -3     
- Misses       34163    34165       +2     
  Partials      2688     2688              
 Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These small changes are only because we have an utilitary type (AtLeast) that is better suited for this situation than the standard Pick; otherwise the PR is fine now.
c426d27    to
    de6a118      
    Compare
  
    Signed-off-by: Abhinav Kumar <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
Signed-off-by: Abhinav Kumar <[email protected]>
de6a118    to
    05f4bb4      
    Compare
  
    
Proposed changes (including videos or screenshots)
This pull request fixes a regression introduced in v7.7.1 where the Directory search stopped returning private channels that the user is a member of.
The query used by the Directory API relies on the
user.__roomsfield to identify which rooms a user has joined.However, this field was not being populated by the authentication handler, resulting in an empty list and causing private channels to be excluded from the Directory search results.
Issue(s)
Steps to test or reproduce
Private_Channel) and ensure the test user is a member.Further comments
SUP-913
Summary by CodeRabbit