Fix field tracking never re-sending fields

This commit is contained in:
Jason Robinson
2026-07-24 15:08:23 +03:00
parent 2a77706ba5
commit 3f3c649492
2 changed files with 29 additions and 5 deletions
+5 -4
View File
@@ -1264,19 +1264,20 @@ class SlidingSyncExtensionHandler:
# We don't use a cache here as for non-lazy sync we always
# send changes and/or fields the client asked for, if relevant
# as above joined condition.
updated_fields: set[str] = updated_user_fields.get(
profile_user_id, set()
)
user_fields = (
user_fields
if profile_user_id in joined_room_user_ids
else set(updated_user_fields.get(profile_user_id, [])).intersection(
profile_data.keys()
)
else updated_fields.intersection(profile_data.keys())
)
for field_name in user_fields:
# Ensure we don't send the field unnecessarely to the client, if
# we've sent it down in this connection before, and it hasn't been
# updated.
if (
field_name in updated_user_fields.keys()
field_name in updated_fields
or previous_connection_state.profile_updates.have_sent_field(
profile_user_id, field_name
).status
@@ -644,12 +644,35 @@ class SlidingSyncProfilesTestCase(SlidingSyncBase):
}
# Make an incremental Sliding Sync request
response_body, _ = self.do_sync(sync_body, since=from_token, tok=self.tok)
response_body, from_token = self.do_sync(
sync_body, since=from_token, tok=self.tok
)
# We should not get other user re-sent
self.assertIsNone(
response_body["extensions"].get("org.matrix.msc4262.profiles"),
)
# Set a new field value and ensure our tracking doesn't swallow updates
self.get_success(
self.profile_handler.set_field(
target_user=UserID.from_string(self.other_user),
requester=create_requester(self.other_user),
field_name="displayname",
new_value="new displayname",
)
)
response_body, _ = self.do_sync(sync_body, since=from_token, tok=self.tok)
self.assertEqual(
response_body["extensions"]["org.matrix.msc4262.profiles"]["users"][
"@other_user:test"
],
{
"updated": {
"displayname": "new displayname",
},
},
)
@override_config({"include_profile_updates_in_sync": True})
def test_removed_fields_get_sent_down_as_removed(self) -> None:
"""