Fix writing delete to profile update stream when displayname or avatar_url are cleared

This commit is contained in:
Jason Robinson
2026-08-17 13:08:52 +03:00
parent 27a304a230
commit dec5ac3454
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -843,7 +843,7 @@ class ProfileWorkerStore(SQLBaseStore):
# Record updates in the profile updates stream
if (
field_name in (ProfileFields.DISPLAYNAME, ProfileFields.AVATAR_URL)
and new_value == ""
and new_value is None
):
# Displayname and avatar_url are special in that they are deleted by
# setting the value to an empty string.
+8 -1
View File
@@ -338,6 +338,8 @@ class ProfileTestCase(unittest.HomeserverTestCase):
),
)
# Set value to empty string. For displayname/avatar_url, this is basically
# a delete of the field. For other fields, it's a value.
self.get_success(
self.handler.set_field(
target_user=self.frank,
@@ -353,9 +355,14 @@ class ProfileTestCase(unittest.HomeserverTestCase):
limit=1,
)
)
expected_action = (
ProfileUpdateAction.DELETE.value
if field_name in (ProfileFields.DISPLAYNAME, ProfileFields.AVATAR_URL)
else ProfileUpdateAction.UPDATE.value
)
self.assertEqual(
delete_updates[0],
(3, "@1234abcd:test", ProfileUpdateAction.UPDATE.value, {field_name}),
(3, "@1234abcd:test", expected_action, {field_name}),
)
@override_config({"include_profile_updates_in_sync": True})