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

Leave out optional keys from /sync #9919

Merged
merged 10 commits into from
May 5, 2021
Prev Previous commit
Next Next commit
Leave out key counts from /sync if empty
Signed-off-by: Nicolas Werner <[email protected]>
  • Loading branch information
deepbluev7 committed May 2, 2021
commit 0dc3c4a6232b310f95b1784dcfcf4a343695b872
15 changes: 9 additions & 6 deletions synapse/rest/client/v2_alpha/sync.py
Original file line number Diff line number Diff line change
@@ -233,12 +233,6 @@ async def encode_response(self, time_now, sync_result, access_token_id, filter):

response: dict = defaultdict(dict)
response["next_batch"] = await sync_result.next_batch.to_string(self.store)
response.update(
{
"device_one_time_keys_count": sync_result.device_one_time_keys_count,
"org.matrix.msc2732.device_unused_fallback_key_types": sync_result.device_unused_fallback_key_types,
}
)

if sync_result.account_data:
response["account_data"] = {"events": sync_result.account_data}
@@ -255,6 +249,15 @@ async def encode_response(self, time_now, sync_result, access_token_id, filter):
if sync_result.device_lists.left:
response["device_lists"]["left"] = list(sync_result.device_lists.left)

if sync_result.device_one_time_keys_count:
response[
"device_one_time_keys_count"
] = sync_result.device_one_time_keys_count
if sync_result.device_unused_fallback_key_types:
response[
"org.matrix.msc2732.device_unused_fallback_key_types"
] = sync_result.device_unused_fallback_key_types

if joined:
response["rooms"]["join"] = joined
if invited: