Don't return empty fields in response

This commit is contained in:
Devon Hudson
2025-10-02 17:23:30 -06:00
parent 4602b56643
commit 24b38733df
3 changed files with 8 additions and 24 deletions
+3 -4
View File
@@ -1142,10 +1142,9 @@ def _serialise_threads(
if threads.updates:
out["updates"] = {
room_id: {
thread_root_id: {
"thread_root": update.thread_root,
"prev_batch": update.prev_batch,
}
thread_root_id: attr.asdict(
update, filter=lambda _attr, v: v is not None
)
for thread_root_id, update in thread_updates.items()
}
for room_id, thread_updates in threads.updates.items()
+3
View File
@@ -412,6 +412,9 @@ class SlidingSyncResult:
# TODO: comment
prev_batch: Optional[StreamToken]
def __bool__(self) -> bool:
return bool(self.thread_root) or bool(self.prev_batch)
updates: Optional[Mapping[str, Mapping[str, ThreadUpdate]]]
prev_batch: Optional[int]
@@ -153,16 +153,7 @@ class SlidingSyncThreadsExtensionTestCase(SlidingSyncBase):
# Assert
self.assertEqual(
response_body["extensions"][EXT_NAME],
{
"updates": {
room_id: {
thread_root_id: {
"thread_root": None,
"prev_batch": None,
}
}
}
},
{"updates": {room_id: {thread_root_id: {}}}},
)
def test_threads_incremental_sync(self) -> None:
@@ -214,14 +205,5 @@ class SlidingSyncThreadsExtensionTestCase(SlidingSyncBase):
# Assert
self.assertEqual(
response_body["extensions"][EXT_NAME],
{
"updates": {
room_id: {
thread_root_id: {
"thread_root": None,
"prev_batch": None,
}
}
}
},
{"updates": {room_id: {thread_root_id: {}}}},
)