Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Do not add groups to sync results if disabled. #12408

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12408.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not include groups in the sync response when disabled.
5 changes: 3 additions & 2 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,9 @@ async def generate_sync_result(
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

Expand Down
15 changes: 7 additions & 8 deletions synapse/rest/client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,13 @@ async def encode_response(
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
Comment on lines -304 to -305
Copy link
Contributor

@DMRobertson DMRobertson Apr 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked this:

_generate_sync_entry_for_groups was computing this and making it non-None. But we're not always calling that function any more, so sync_result.groups may well be None.

(I'm not quite sure why .groups was allowed to be None in the first place? But it's going away soon anyway.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for double check, that was what I found as well! 👍 (I also ran some sync tests after disabling groups and nothing 💥 ...)

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

Expand Down