summary refs log tree commit diff
path: root/synapse/visibility.py
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2023-03-08 18:44:00 +0000
committerDavid Robertson <davidr@element.io>2023-03-10 11:55:40 +0000
commitfa5ca2edea333df58e0bf254c95215b0dbf5c199 (patch)
treef09e727d0deace121ae569a9ee813682396e3745 /synapse/visibility.py
parentFlip logic and provide better name (diff)
downloadsynapse-fa5ca2edea333df58e0bf254c95215b0dbf5c199.tar.xz
Separate decision from action
Diffstat (limited to 'synapse/visibility.py')
-rw-r--r--synapse/visibility.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/synapse/visibility.py b/synapse/visibility.py
index cb9a2d1e0a..5501b636f5 100644
--- a/synapse/visibility.py
+++ b/synapse/visibility.py
@@ -669,8 +669,7 @@ async def filter_events_for_server(
         target_server_name,
     )
 
-    to_return = []
-    for e in events:
+    def include_event_in_output(e: EventBase) -> bool:
         erased = is_sender_erased(e, erased_senders)
         visible = check_event_is_visible(
             event_to_history_vis[e.event_id], event_to_memberships.get(e.event_id, {})
@@ -679,7 +678,11 @@ async def filter_events_for_server(
         if e in partial_state_invisible_events:
             visible = False
 
-        if visible and not erased:
+        return visible and not erased
+
+    to_return = []
+    for e in events:
+        if include_event_in_output(e):
             to_return.append(e)
         elif redact:
             to_return.append(prune_event(e))