summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2022-04-07 09:29:56 -0400
committerGitHub <noreply@github.com>2022-04-07 09:29:56 -0400
commit1a90c1e3af71fe57c5a4bce52c60e6cd7509b0c2 (patch)
tree005baebbda094b30147fe92db5a4cf9669ddee05
parentAdd opentracing spans to calls to external cache (#12380) (diff)
downloadsynapse-1a90c1e3af71fe57c5a4bce52c60e6cd7509b0c2.tar.xz
Do not add groups to sync results if disabled. (#12408)
-rw-r--r--changelog.d/12408.misc1
-rw-r--r--synapse/handlers/sync.py5
-rw-r--r--synapse/rest/client/sync.py15
3 files changed, 11 insertions, 10 deletions
diff --git a/changelog.d/12408.misc b/changelog.d/12408.misc
new file mode 100644
index 0000000000..e09a6b8423
--- /dev/null
+++ b/changelog.d/12408.misc
@@ -0,0 +1 @@
+Do not include groups in the sync response when disabled.
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 303c38c746..a91cea6e48 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -1155,8 +1155,9 @@ class SyncHandler:
                 await self.store.get_e2e_unused_fallback_key_types(user_id, device_id)
             )
 
-        logger.debug("Fetching group data")
-        await self._generate_sync_entry_for_groups(sync_result_builder)
+        if self.hs_config.experimental.groups_enabled:
+            logger.debug("Fetching group data")
+            await self._generate_sync_entry_for_groups(sync_result_builder)
 
         num_events = 0
 
diff --git a/synapse/rest/client/sync.py b/synapse/rest/client/sync.py
index 0bf32f873b..2e25e8638b 100644
--- a/synapse/rest/client/sync.py
+++ b/synapse/rest/client/sync.py
@@ -301,14 +301,13 @@ class SyncRestServlet(RestServlet):
         if archived:
             response["rooms"][Membership.LEAVE] = archived
 
-        # By the time we get here groups is no longer optional.
-        assert sync_result.groups is not None
-        if sync_result.groups.join:
-            response["groups"][Membership.JOIN] = sync_result.groups.join
-        if sync_result.groups.invite:
-            response["groups"][Membership.INVITE] = sync_result.groups.invite
-        if sync_result.groups.leave:
-            response["groups"][Membership.LEAVE] = sync_result.groups.leave
+        if sync_result.groups is not None:
+            if sync_result.groups.join:
+                response["groups"][Membership.JOIN] = sync_result.groups.join
+            if sync_result.groups.invite:
+                response["groups"][Membership.INVITE] = sync_result.groups.invite
+            if sync_result.groups.leave:
+                response["groups"][Membership.LEAVE] = sync_result.groups.leave
 
         return response