From 3952297f6f39906a65e70bce7becc1acd300a287 Mon Sep 17 00:00:00 2001
From: Patrick Cloke <clokep@users.noreply.github.com>
Date: Wed, 11 Jan 2023 07:16:41 -0500
Subject: [PATCH] Calculate rooms changed for device lists to work. (#14810)

Back-out some changes from 7e582a25f8f350df29d7d83ca902bdb522d1bbaf
(#14786) which skipped necessary logic to calculate device lists properly.
---
 changelog.d/14810.bugfix | 1 +
 synapse/api/filtering.py | 3 ---
 synapse/handlers/sync.py | 4 ----
 3 files changed, 1 insertion(+), 7 deletions(-)
 create mode 100644 changelog.d/14810.bugfix

diff --git a/changelog.d/14810.bugfix b/changelog.d/14810.bugfix
new file mode 100644
index 0000000000..379bfccffa
--- /dev/null
+++ b/changelog.d/14810.bugfix
@@ -0,0 +1 @@
+Fix a bug introduced in Synapse 1.75.0rc1 where device lists could be miscalculated with some sync filters.
diff --git a/synapse/api/filtering.py b/synapse/api/filtering.py
index 2b5af264b4..4cf8f0cc8e 100644
--- a/synapse/api/filtering.py
+++ b/synapse/api/filtering.py
@@ -283,9 +283,6 @@ class FilterCollection:
             await self._room_filter.filter(events)
         )
 
-    def blocks_all_rooms(self) -> bool:
-        return self._room_filter.filters_all_rooms()
-
     def blocks_all_presence(self) -> bool:
         return (
             self._presence_filter.filters_all_types()
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 6942e06c77..20ee2f203a 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -1793,10 +1793,6 @@ class SyncHandler:
             - newly_left_users
         """
 
-        # If the request doesn't care about rooms then nothing to do!
-        if sync_result_builder.sync_config.filter_collection.blocks_all_rooms():
-            return set(), set(), set(), set()
-
         since_token = sync_result_builder.since_token
 
         # 1. Start by fetching all ephemeral events in rooms we've joined (if required).
-- 
GitLab