summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorreivilibre <oliverw@matrix.org>2022-02-18 14:54:31 +0000
committerGitHub <noreply@github.com>2022-02-18 14:54:31 +0000
commiteb609c65d0794dd49efcd924bdc8743fd4253a93 (patch)
tree39854d74acb1e7eb093f817c25db3c033a1b865d /synapse/storage
parentAdvertise Matrix 1.1 in `/_matrix/client/versions` (#12020) (diff)
downloadsynapse-eb609c65d0794dd49efcd924bdc8743fd4253a93.tar.xz
Fix bug in `StateFilter.return_expanded()` and add some tests. (#12016)
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/state.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py
index 913448f0f9..e79ecf64a0 100644
--- a/synapse/storage/state.py
+++ b/synapse/storage/state.py
@@ -204,13 +204,16 @@ class StateFilter:
         if get_all_members:
             # We want to return everything.
             return StateFilter.all()
-        else:
+        elif EventTypes.Member in self.types:
             # We want to return all non-members, but only particular
             # memberships
             return StateFilter(
                 types=frozendict({EventTypes.Member: self.types[EventTypes.Member]}),
                 include_others=True,
             )
+        else:
+            # We want to return all non-members
+            return _ALL_NON_MEMBER_STATE_FILTER
 
     def make_sql_filter_clause(self) -> Tuple[str, List[str]]:
         """Converts the filter to an SQL clause.
@@ -528,6 +531,9 @@ class StateFilter:
 
 
 _ALL_STATE_FILTER = StateFilter(types=frozendict(), include_others=True)
+_ALL_NON_MEMBER_STATE_FILTER = StateFilter(
+    types=frozendict({EventTypes.Member: frozenset()}), include_others=True
+)
 _NONE_STATE_FILTER = StateFilter(types=frozendict(), include_others=False)