- 
                Notifications
    You must be signed in to change notification settings 
- Fork 414
MSC2666: Get rooms in common with another user #2666
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
          
     Open
      
      
            Half-Shot
  wants to merge
  30
  commits into
  old_master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
hs/shared-rooms
  
      
      
   
  
    
  
  
  
 
  
      
    base: old_master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 10 commits
      Commits
    
    
            Show all changes
          
          
            30 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      c61790e
              
                MSC 2664: Get rooms in common with another user
              
              
                Half-Shot 4264f32
              
                correct MSC number
              
              
                Half-Shot 008951f
              
                Try to clarify Proposal, update response format
              
              
                Half-Shot 29f02ed
              
                Update MSC number in prefix
              
              
                Half-Shot 2b75da8
              
                Wording tidyup
              
              
                Half-Shot 630af1c
              
                more tidyup
              
              
                Half-Shot d885bcf
              
                Clarify empty responses
              
              
                Half-Shot 5254076
              
                uhoreg fixes my spelling
              
              
                Half-Shot 3f2faef
              
                add same user case
              
              
                Half-Shot db99583
              
                Update to use /uk.half-shot.msc2666/
              
              
                Half-Shot 10a2df2
              
                Fixes
              
              
                Half-Shot d3b17e6
              
                Merge branch 'hs/shared-rooms' of github.com:matrix-org/matrix-doc in…
              
              
                Half-Shot 4ac7ce8
              
                remove referneces to user_id
              
              
                Half-Shot a4f5bae
              
                another reference to the auth user id
              
              
                Half-Shot c453704
              
                consistent newlines
              
              
                Half-Shot cd173d5
              
                Add errcode
              
              
                Half-Shot 1a389f9
              
                Update proposals/2666-get-rooms-in-common.md
              
              
                Half-Shot fbbb2d9
              
                typo fix and shared_rooms -> mutual_rooms (#3631)
              
              
                ShadowJonathan 591d3e5
              
                Apply suggestions from code review
              
              
                Half-Shot a1de65f
              
                @MSC2666: Add "may return 400" qualifier (#3770)
              
              
                ShadowJonathan d59d051
              
                Reject r0, embrace v1
              
              
                Half-Shot 6a4e523
              
                Remove M_UNKNOWN response (#3822)
              
              
                ShadowJonathan b946cc3
              
                Update an old link to the spec; fix endpoint text
              
              
                anoadragon453 ea49670
              
                provide a link to lazy-loading of room members spec
              
              
                anoadragon453 6f4f01b
              
                Apply review feedback (#3913)
              
              
                ShadowJonathan 60ae94f
              
                Add invalid batch_token error code (#4017)
              
              
                ShadowJonathan 7829c3b
              
                Update proposals/2666-get-rooms-in-common.md
              
              
                anoadragon453 92aef5b
              
                restrict the allowed characters for the next_batch_token
              
              
                anoadragon453 d58d0a1
              
                apply review feedback (#4035)
              
              
                ShadowJonathan d0c4cd2
              
                Update path
              
              
                Half-Shot File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # MSC 2666: Get rooms in common with another user | ||
|         
                  anoadragon453 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| It is useful to be able to fetch rooms you have in common with another user. Popular messaging services | ||
| such as Telegram offer users the ability to show "groups in common", which allows users to determine | ||
| what they have in common before participating in converstion. | ||
|  | ||
| There are a variety of applications for this information. Some users may want to block invites from | ||
| users they do not share a room with at the client level, and need a way to poll the homeserver for | ||
| this information. Another use case would be trying to determine how a user came across your mxid, as | ||
| invites on their own do not present much context. With this endpoint, a client could tell you what | ||
| rooms you have in common before you accept an invite. | ||
|  | ||
| While this information can be determined if the user has full access to member state for all rooms, | ||
| modern clients often implement "lazy-loading", so they often only have a subset of state for the rooms | ||
| the user is in. Therefore, the homeserver should have a means to provide this information. | ||
|  | ||
| This proposal aims to implement a simple mechanism to fetch rooms you have in common with another user. | ||
|  | ||
| ## Proposal | ||
|  | ||
| Homeservers should implement a new endpoint `/users/{current_user}/shared_rooms/{other_user_id}` which will take | ||
|         
                  Half-Shot marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| the authenticated user's MxID and the user that is being searched for. | ||
|  | ||
| The response format will be an array containing all rooms where both the `current_user` and `other_user_id` have | ||
| a membership of type `join`. If either user is not joined to any rooms, or the `other_user_id` does not exist, an | ||
|         
                  Half-Shot marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| empty array should be returned. If the `current_user` and `other_user_id` are the same, then the endpoint SHOULD | ||
| reject with HTTP 400. | ||
|  | ||
| ``` | ||
| GET _matrix/client/unstable/uk.half-shot.msc2666/users/@alice:example.com/shared_rooms/@bob:example.com | ||
|         
                  Half-Shot marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved         
                  Half-Shot marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| ``` | ||
|  | ||
| ```json | ||
| { | ||
| "rooms": [ | ||
| "!OGEhHVWSdvArJzumhm:matrix.org", | ||
|         
                  turt2live marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| "!HYlSnuBHTxUPgyZPKC:half-shot.uk", | ||
| "!DueayyFpVTeVOQiYjR:example.com" | ||
| ] | ||
| } | ||
| ``` | ||
|  | ||
|         
                  anoadragon453 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| ## Potential issues | ||
|  | ||
| Homeserver performance and storage may be impacted by this endpoint. While a homeserver already stores | ||
| membership information for each of its users, the information may not be stored in a way that is readily | ||
| accessible. Homeservers that have implemented [POST /user-directory/search](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-user-directory-search) | ||
| may have started some of this work, if they are limiting users to searching for users for which they | ||
| share rooms. While this is not a given by any means, it may mean that implementations of this API | ||
| and /search may be complimentary. | ||
|  | ||
|  | ||
| ## Alternatives | ||
|         
                  anoadragon453 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| A client can already read all membership for all rooms, and thus determine which of those rooms contains | ||
| a "join" membership for the given user_id. However, this method is computationally expensive on the homeserver | ||
| and the client. Furthermore, it would increase total network traffic (which is important for low bandwith / mobile clients) | ||
| as well as include lots of extranious information. | ||
|         
                  Half-Shot marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
|  | ||
| ## Security considerations | ||
|  | ||
| The information provided in this endpoint is already accessible to the client if it has a copy of all | ||
| state that the user can see. This endpoint only makes it possible to get this information without having | ||
| to request all state ahead of time. | ||
|  | ||
|  | ||
| ## Unstable prefix | ||
|  | ||
| The implementation MUST use `/_matrix/client/unstable/uk.half-shot.msc2666/users/{user_id}/shared_rooms/{other_user_id}`. | ||
| The /versions endpoint MUST include a new key in `unstable_features` with the name `uk.half-shot.msc2666`. | ||
|         
                  anoadragon453 marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| Once the MSC has been merged, clients should use `/_matrix/client/r0/users/{user_id}/shared_rooms/{other_user_id}` | ||
| and will no longer need to check for the `unstable_features` flag. | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.