mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-22 03:40:27 +00:00
Fix writing delete to profile update stream when displayname or avatar_url are cleared
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user