mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-29 09:58:34 +00:00
Don't return empty fields in response
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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: {}}}},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user