mirror of
https://github.com/zulip/zulip.git
synced 2025-11-20 06:28:23 +00:00
actions: Fix type-incorrect custom profile field value assignment.
The old assignment is incorrect - field_value.value is a TextField() and should always be a string. This didn't strictly break anything, because django converts the value to a string when .save()ing to the db, but field_value.value persists as a non-string for the rest of this codepath. After fixing this, the small codeblock in notify_user_update_custom_profile_data handling conversion of field_value.value to a string becomes redundant. We're assured that we're not breaking event format by the test test_custom_profile_field_data_events in test_events.py.
This commit is contained in:
committed by
Tim Abbott
parent
c4edda016f
commit
91ea21a3fc
@@ -7727,11 +7727,8 @@ def try_reorder_realm_custom_profile_fields(realm: Realm, order: List[int]) -> N
|
|||||||
def notify_user_update_custom_profile_data(
|
def notify_user_update_custom_profile_data(
|
||||||
user_profile: UserProfile, field: Dict[str, Union[int, str, List[int], None]]
|
user_profile: UserProfile, field: Dict[str, Union[int, str, List[int], None]]
|
||||||
) -> None:
|
) -> None:
|
||||||
data = dict(id=field["id"])
|
data = dict(id=field["id"], value=field["value"])
|
||||||
if field["type"] == CustomProfileField.USER:
|
|
||||||
data["value"] = orjson.dumps(field["value"]).decode()
|
|
||||||
else:
|
|
||||||
data["value"] = field["value"]
|
|
||||||
if field["rendered_value"]:
|
if field["rendered_value"]:
|
||||||
data["rendered_value"] = field["rendered_value"]
|
data["rendered_value"] = field["rendered_value"]
|
||||||
payload = dict(user_id=user_profile.id, custom_profile_field=data)
|
payload = dict(user_id=user_profile.id, custom_profile_field=data)
|
||||||
@@ -7756,7 +7753,7 @@ def do_update_user_custom_profile_data_if_changed(
|
|||||||
# to a string for the comparison in this if.
|
# to a string for the comparison in this if.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
field_value.value = custom_profile_field["value"]
|
field_value.value = str(custom_profile_field["value"])
|
||||||
if field_value.field.is_renderable():
|
if field_value.field.is_renderable():
|
||||||
field_value.rendered_value = render_stream_description(
|
field_value.rendered_value = render_stream_description(
|
||||||
str(custom_profile_field["value"])
|
str(custom_profile_field["value"])
|
||||||
|
|||||||
Reference in New Issue
Block a user