Ensure lazy loaded profile updates in sync contain full profiles for users in timeline

This commit is contained in:
Jason Robinson
2026-06-23 12:39:07 +03:00
parent 27417cf0a8
commit daa8d7a28d
2 changed files with 36 additions and 4 deletions
+13 -4
View File
@@ -2316,10 +2316,19 @@ class SyncHandler:
continue
per_user_updates: dict[str, JsonValue] = {}
for field_name in fields:
per_user_updates[field_name] = cast(
JsonValue, profile_data.get(field_name)
)
if include_users and other_user_id in include_users:
# Include the full profile as this user has events in
# a lazy loaded sync response
for field_name in profile_data.keys():
per_user_updates[field_name] = cast(
JsonValue, profile_data.get(field_name)
)
else:
# Include only the diff
for field_name in fields:
per_user_updates[field_name] = cast(
JsonValue, profile_data.get(field_name)
)
if per_user_updates:
profile_updates[other_user_id] = per_user_updates
+23
View File
@@ -1383,6 +1383,10 @@ class SyncProfileUpdatesTestCase(tests.unittest.HomeserverTestCase):
incremental_result.profile_updates["@other_user:test"]["m.status"],
'{"text": "On holiday", "emoji": "\\ud83c\\udfd6"}',
)
# We only send diffs in incremental sync for profile field updates
self.assertIsNone(
incremental_result.profile_updates["@other_user:test"].get("displayname"),
)
@override_config({"experimental_features": {"msc4429_enabled": True}})
def test_incremental_sync_does_not_filter_profile_updates_when_lazy_loading(
@@ -1468,6 +1472,25 @@ class SyncProfileUpdatesTestCase(tests.unittest.HomeserverTestCase):
"@third_user:test",
],
)
# This is a field upfate, so should be here
self.assertEqual(
incremental_result.profile_updates["@other_user:test"]["m.status"],
'{"text": "On holiday", "emoji": "\\ud83c\\udfd6"}',
)
# We don't have events for this user in this response, so their full profile
# is not included
self.assertIsNone(
incremental_result.profile_updates["@other_user:test"].get("displayname"),
)
# This user has events in the timeline, thus their full profile is included
self.assertEqual(
incremental_result.profile_updates["@third_user:test"]["m.status"],
'{"text": "On fire", "emoji": "\\ud83d\\udd25"}',
)
self.assertEqual(
incremental_result.profile_updates["@third_user:test"]["displayname"],
"third_user",
)
class SyncStateAfterTestCase(tests.unittest.HomeserverTestCase):