diff options
author | Eric Eastwood <eric.eastwood@beta.gouv.fr> | 2024-06-24 19:07:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-24 19:07:56 -0500 |
commit | 6e8af8319373e1ab470f1d8eee0420f3be84184f (patch) | |
tree | 49f58868fb911592b76dc55251c9fb267d999589 /synapse | |
parent | Correct error in user_directory docs (#17348) (diff) | |
download | synapse-6e8af8319373e1ab470f1d8eee0420f3be84184f.tar.xz |
Add `is_invite` filtering to Sliding Sync `/sync` (#17335)
Based on [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575): Sliding Sync
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/handlers/sliding_sync.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/synapse/handlers/sliding_sync.py b/synapse/handlers/sliding_sync.py index 16d94925f5..847a638bba 100644 --- a/synapse/handlers/sliding_sync.py +++ b/synapse/handlers/sliding_sync.py @@ -554,7 +554,7 @@ class SlidingSyncHandler: # Flatten out the map dm_room_id_set = set() - if dm_map: + if isinstance(dm_map, dict): for room_ids in dm_map.values(): # Account data should be a list of room IDs. Ignore anything else if isinstance(room_ids, list): @@ -593,8 +593,21 @@ class SlidingSyncHandler: ): filtered_room_id_set.remove(room_id) - if filters.is_invite: - raise NotImplementedError() + # Filter for rooms that the user has been invited to + if filters.is_invite is not None: + # Make a copy so we don't run into an error: `Set changed size during + # iteration`, when we filter out and remove items + for room_id in list(filtered_room_id_set): + room_for_user = sync_room_map[room_id] + # If we're looking for invite rooms, filter out rooms that the user is + # not invited to and vice versa + if ( + filters.is_invite and room_for_user.membership != Membership.INVITE + ) or ( + not filters.is_invite + and room_for_user.membership == Membership.INVITE + ): + filtered_room_id_set.remove(room_id) if filters.room_types: raise NotImplementedError() |